diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index dd37961a2..6788f82a5 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -66,6 +66,28 @@ "litellm_provider": "openai", "mode": "chat" }, + "gpt-4-turbo": { + "max_tokens": 4096, + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "input_cost_per_token": 0.00001, + "output_cost_per_token": 0.00003, + "litellm_provider": "openai", + "mode": "chat", + "supports_function_calling": true, + "supports_parallel_function_calling": true + }, + "gpt-4-turbo-2024-04-09": { + "max_tokens": 4096, + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "input_cost_per_token": 0.00001, + "output_cost_per_token": 0.00003, + "litellm_provider": "openai", + "mode": "chat", + "supports_function_calling": true, + "supports_parallel_function_calling": true + }, "gpt-4-1106-preview": { "max_tokens": 4096, "max_input_tokens": 128000, diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index c5800937b..ca23077e9 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

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

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-6e76bea15b095033.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-6e76bea15b095033.js deleted file mode 100644 index de0b14489..000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-6e76bea15b095033.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,l,t){Promise.resolve().then(t.bind(t,75662))},75662:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return eQ}});var s=t(3827),a=t(64090),r=t(47907),n=t(8792),o=t(40491),i=t(65270),c=e=>{let{userID:l,userRole:t,userEmail:a,showSSOBanner:r}=e;console.log("User ID:",l),console.log("userEmail:",a),console.log("showSSOBanner:",r);let c=[{key:"1",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{children:["Role: ",t]}),(0,s.jsxs)("p",{children:["ID: ",l]})]})}];return(0,s.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,s.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,s.jsx)("div",{className:"flex flex-col items-center",children:(0,s.jsx)(n.default,{href:"/",children:(0,s.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,s.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,s.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,s.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,s.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Request hosted proxy"})}):null,(0,s.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,s.jsx)(o.Z,{menu:{items:c},children:(0,s.jsx)(i.Z,{children:a})})})]})]})},d=t(80588);let m=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),d.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete key: "+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}},p=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},j=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0,r=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&r&&(n="".concat(n,"?view_all=true&page=").concat(a,"&page_size=").concat(r));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw d.ZP.error(e),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},g=async e=>{try{let l=await fetch("/global/spend",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{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 t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},Z=async(e,l,t)=>{try{let l=await fetch("/model/metrics",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,l,t)=>{try{let l=await fetch("/models",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{let t="/global/spend/logs";console.log("in keySpendLogsCall:",t);let s=await fetch("".concat(t,"?api_key=").concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{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}},k=async e=>{try{let l="/global/spend/tags";console.log("in tagsSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t,s,a,r)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(a,"&end_date=").concat(r):"".concat(l,"?start_date=").concat(a,"&end_date=").concat(r);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw d.ZP.error(e),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},v=async e=>{try{let l=await fetch("/global/spend/logs",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l)=>{try{l&&JSON.stringify({api_key:l});let t={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};l&&(t.body=JSON.stringify({api_key:l}));let s=await fetch("/global/spend/end_users",t);if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},A=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});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}},I=async e=>{try{let l="/user/get_requests";console.log("in userGetRequesedtModelsCall:",l);let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to get requested models:",e),e}},P=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},T=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to update key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member: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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let a=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!a.ok){let e=await a.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 a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l)=>{try{let t=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:l})});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}},U=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{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")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},D=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});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 set callbacks:",e),e}};var L=t(10384),z=t(46453),B=t(2179),K=t(71801),q=t(42440),V=t(42308),G=t(50670),J=t(81583),W=t(77171),Y=t(42539),$=t(88707),H=t(1861);let{Option:X}=G.default;var Q=e=>{let{userID:l,team:t,userRole:r,accessToken:n,data:o,setData:i}=e,[c]=J.Z.useForm(),[m,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(null),[j,g]=(0,a.useState)(null),[y,Z]=(0,a.useState)([]),w=()=>{u(!1),c.resetFields()},b=()=>{u(!1),p(null),c.resetFields()};(0,a.useEffect)(()=>{(async()=>{try{if(null===l||null===r)return;if(null!==n){let e=(await f(n,l,r)).data.map(e=>e.id);console.log("available_model_names:",e),Z(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,r]);let k=async e=>{try{d.ZP.info("Making API Call"),u(!0);let t=await h(n,l,e);console.log("key create Response:",t),i(e=>e?[...e,t]:[t]),p(t.key),g(t.soft_budget),d.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,s.jsx)(W.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:w,onCancel:b,children:(0,s.jsxs)(J.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===r||"Admin"===r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,s.jsx)(Y.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(X,{value:"all-team-models",children:"All Team Models"},"all-team-models"),t&&t.models?t.models.includes("all-proxy-models")?y.map(e=>(0,s.jsx)(X,{value:e,children:e},e)):t.models.map(e=>(0,s.jsx)(X,{value:e,children:e},e)):y.map(e=>(0,s.jsx)(X,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,s.jsxs)(G.default,{defaultValue:null,placeholder:"n/a",children:[(0,s.jsx)(G.default.Option,{value:"24h",children:"daily"}),(0,s.jsx)(G.default.Option,{value:"30d",children:"monthly"})]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Metadata",name:"metadata",children:(0,s.jsx)(Y.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,s.jsx)(Y.Z,{placeholder:"default team (create a new team)"})}),(0,s.jsx)(J.Z.Item,{label:"Description",name:"description",children:(0,s.jsx)(Y.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,s.jsx)(W.Z,{visible:m,onOk:w,onCancel:b,footer:null,children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 w-full",children:[(0,s.jsx)(q.Z,{children:"Save your Key"}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,s.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:null!=x?(0,s.jsxs)("div",{children:[(0,s.jsx)(K.Z,{className:"mt-3",children:"API Key:"}),(0,s.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,s.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,s.jsx)(V.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,s.jsx)(B.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,s.jsx)(K.Z,{children:"Key being created, this might take 30s"})})]})})]})},ee=t(9454),el=t(98941),et=t(33393),es=t(5),ea=t(9853),er=t(13810),en=t(39290),eo=t(66952),ei=t(61244),ec=t(10827),ed=t(3851),em=t(2044),eh=t(64167),eu=t(74480),ex=t(7178);let{Option:ep}=G.default;var ej=e=>{let{userID:l,userRole:t,accessToken:r,selectedTeam:n,data:o,setData:i}=e,[c,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[p,j]=(0,a.useState)(null),[g,y]=a.useState(null),[Z,b]=(0,a.useState)(null),[k,_]=(0,a.useState)(null),[v,S]=(0,a.useState)(""),[N,A]=(0,a.useState)(!1),[C,I]=(0,a.useState)(null),[P,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==r&&null!==t){let e=(await f(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),T(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let F=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),I(e),A(!0)},O=async e=>{if(null==r)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await E(r,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),d.ZP.success("Key updated successfully"),A(!1),I(null)},M=async e=>{try{if(null==r||null==e)return;console.log("accessToken: ".concat(r,"; token: ").concat(e.token));let l=await w(r,e.token);console.log("Response:",l),_(l);try{let e=await R(r,l);console.log("Response2:",e);let t=[...l,...e.response];_(t),S(e.predicted_spend),console.log("Combined Data:",t)}catch(e){console.error("There was an error fetching the predicted data",e)}}catch(e){console.error("There was an error fetching the data",e)}};(0,a.useEffect)(()=>{M(Z)},[Z]);let U=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),u(!0))},D=async()=>{if(null!=p&&null!=o){try{await x(r,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}u(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,s.jsxs)("div",{children:[(0,s.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Key Alias"}),(0,s.jsx)(eu.Z,{children:"Secret Key"}),(0,s.jsx)(eu.Z,{children:"Spend (USD)"}),(0,s.jsx)(eu.Z,{children:"Budget (USD)"}),(0,s.jsx)(eu.Z,{children:"Models"}),(0,s.jsx)(eu.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ed.Z,{children:o.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||n&&e.team_id!=n.team_id)?null:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,s.jsx)(K.Z,{children:e.key_alias}):(0,s.jsx)(K.Z,{children:"Not Set"})}),(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:e.key_name})}),(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,s.jsx)(em.Z,{children:null!=e.max_budget?(0,s.jsx)(K.Z,{children:e.max_budget}):(0,s.jsx)(K.Z,{children:"Unlimited"})}),(0,s.jsx)(em.Z,{children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(s.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Team Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Team Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,s.jsx)(em.Z,{children:(0,s.jsxs)(K.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{onClick:()=>{b(e),y(e.id)},icon:ee.Z,size:"sm"}),(0,s.jsx)(en.Z,{open:null!==g,onClose:()=>{y(null),b(null)},children:(0,s.jsx)(eo.Z,{children:Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(Z.spend).toFixed(4)}catch(e){return Z.spend}})()})})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.max_budget?(0,s.jsx)(s.Fragment,{children:Z.max_budget}):(0,s.jsx)(s.Fragment,{children:"Unlimited"})})})]},e.name),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.expires?(0,s.jsx)(s.Fragment,{children:new Date(Z.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,s.jsx)(s.Fragment,{children:"Never"})})})]},e.name)]}),(0,s.jsx)(er.Z,{className:"mt-6 mb-6",children:k&&(0,s.jsx)(ea.Z,{className:"mt-6",data:k,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,s.jsx)(q.Z,{children:"Metadata"}),(0,s.jsx)(K.Z,{children:JSON.stringify(Z.metadata)}),(0,s.jsx)(B.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{y(null),b(null)},children:"Close"})]})})}),(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>F(e)}),(0,s.jsx)(ei.Z,{onClick:()=>U(e),icon:et.Z,size:"sm"})]})]},e.token))})]}),h&&(0,s.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,s.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,s.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,s.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,s.jsx)("div",{className:"sm:flex sm:items-start",children:(0,s.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,s.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,s.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.Z,{onClick:D,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{u(!1),j(null)},children:"Cancel"})]})]})]})})]}),C&&(0,s.jsx)(e=>{let{visible:l,onCancel:t,token:a,onSubmit:r}=e,[o]=J.Z.useForm();return console.log("in edit key modal:",a),console.log("in edit key modal, team:",n),(0,s.jsx)(W.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,s.jsxs)(J.Z,{form:o,onFinish:O,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(ep,{value:"all-team-models",children:"All Team Models"},"all-team-models"),n&&n.models?n.models.includes("all-proxy-models")?P.filter(e=>"all-proxy-models"!==e).map(e=>(0,s.jsx)(ep,{value:e,children:e},e)):n.models.map(e=>(0,s.jsx)(ep,{value:e,children:e},e)):P.map(e=>(0,s.jsx)(ep,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==n?void 0:n.max_budget)!==null&&(null==n?void 0:n.max_budget)!==void 0?null==n?void 0:n.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&n&&null!==n.max_budget&&l>n.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(n.max_budget))}}],children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"token",name:"token",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:N,onCancel:()=>{A(!1),I(null)},token:C,onSubmit:O})]})},eg=e=>{let{userID:l,userRole:t,accessToken:r}=e,[n,o]=(0,a.useState)(0),[i,c]=(0,a.useState)(0);(0,a.useEffect)(()=>{(async()=>{if(r&&l&&t&&"Admin"===t)try{let e=await g(r);e&&(e.spend?o(e.spend):o(0),e.max_budget?c(e.max_budget):c(0))}catch(e){console.error("Error fetching global spend data:",e)}})()},[t,r]);let d=void 0!==n?n.toFixed(5):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend (across all teams)"}),(0,s.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",d]})]})},ey=t(55901),eZ=t(27166),ef=e=>{let{teams:l,setSelectedTeam:t}=e,r={models:[],team_id:null,team_alias:"Default Team"},[n,o]=(0,a.useState)(r),i=l?[...l,r]:[r];return(0,s.jsxs)("div",{className:"mt-5 mb-5",children:[(0,s.jsx)(q.Z,{children:"Select Team"}),(0,s.jsx)(K.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,s.jsxs)(K.Z,{className:"mt-3 mb-3",children:[(0,s.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),i&&i.length>0?(0,s.jsx)(ey.Z,{defaultValue:"0",children:i.map((e,l)=>(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,s.jsxs)(K.Z,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]})},ew=t(37963),eb=t(36083);console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:t,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,a.useState)(null),p=(0,r.useSearchParams)();p.get("viewSpend"),(0,r.useRouter)();let y=p.get("token"),[Z,w]=(0,a.useState)(null),[b,k]=(0,a.useState)([]),[_,v]=(0,a.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,a.useEffect)(()=>{if(y){let e=(0,ew.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&Z&&t&&!o&&!u){let e=sessionStorage.getItem("userModels"+l);e?k(JSON.parse(e)):(async()=>{try{let e=await j(Z,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await g(Z);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams),v(e.teams?e.teams[0]:null),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let s=(await f(Z,l,t)).data.map(e=>e.id);console.log("available_model_names:",s),k(s),console.log("userModels:",b),sessionStorage.setItem("userModels"+l,JSON.stringify(s))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,Z,o,t]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==Z)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",_),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(eg,{userID:l,userRole:t,accessToken:Z}),(0,s.jsx)(ej,{userID:l,userRole:t,accessToken:Z,selectedTeam:_||null,data:o,setData:h}),(0,s.jsx)(Q,{userID:l,team:_||null,userRole:t,accessToken:Z,data:o,setData:h},_?_.team_id:null),(0,s.jsx)(ef,{teams:n,setSelectedTeam:v})]})})})},e_=t(92836),ev=t(26734),eS=t(41608),eN=t(32126),eA=t(23682),eC=t(52273),eI=t(38302),eP=t(28683),eT=t(1460),eE=t(78578);let{Title:eF,Link:eO}=eb.default;var eM=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,[o,i]=(0,a.useState)({data:[]}),[c,h]=(0,a.useState)([]),[u,x]=(0,a.useState)([]),[p]=J.Z.useForm(),[j,g]=(0,a.useState)("OpenAI");if((0,a.useEffect)(()=>{if(!l||!t||!r||!n)return;let e=async()=>{try{let e=await y(l,n,r);console.log("Model data response:",e.data),i(e);let t=await Z(l,n,r);if(console.log("Model metrics response:",t),h(t),"Admin"===r&&l){let e=await I(l);console.log("Pending Requests:",u),x(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&n&&e()},[l,t,r,n]),!o||!l||!t||!r||!n)return(0,s.jsx)("div",{children:"Loading..."});let f=[];for(let e=0;e{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=n,o.data[e].output_cost=i,o.data[e].max_tokens=c,o.data[e].api_base=null==l?void 0:null===(b=l.litellm_params)||void 0===b?void 0:b.api_base,o.data[e].cleanedLitellmParams=d,f.push(l.model_name),console.log(o.data[e])}if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let k=async e=>{try{let t={},s={},a="";for(let[l,r]of Object.entries(e))if("model_name"==l&&(a=r),("api_key"===l||"model"===l||"api_base"===l||"api_version"===l||l.startsWith("aws_"))&&(t[l]=r),"base_model"===l&&(s[l]=r),"litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw d.ZP.error("Failed to parse LiteLLM Extra Params: "+e),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}let r={model_name:a,litellm_params:t,model_info:s},n=await m(l,r);p.resetFields(),console.log("response for model create call: ".concat(n.data))}catch(e){d.ZP.error("Failed to create model: "+e)}};return console.log("selectedProvider: ".concat(j)),(0,s.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,s.jsxs)(ev.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(eS.Z,{className:"mt-2",children:[(0,s.jsx)(e_.Z,{children:"All Models"}),(0,s.jsx)(e_.Z,{children:"Add Model"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{children:[(0,s.jsx)(er.Z,{children:(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Model Name "}),(0,s.jsx)(eu.Z,{children:"Provider"}),"Admin"===r&&(0,s.jsx)(eu.Z,{children:"API Base"}),(0,s.jsx)(eu.Z,{children:"Extra litellm Params"}),(0,s.jsx)(eu.Z,{children:"Input Price per token ($)"}),(0,s.jsx)(eu.Z,{children:"Output Price per token ($)"}),(0,s.jsx)(eu.Z,{children:"Max Tokens"})]})}),(0,s.jsx)(ed.Z,{children:o.data.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:e.model_name})}),(0,s.jsx)(em.Z,{children:e.provider}),"Admin"===r&&(0,s.jsx)(em.Z,{children:e.api_base}),(0,s.jsx)(em.Z,{children:(0,s.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})}),(0,s.jsx)(em.Z,{children:e.input_cost}),(0,s.jsx)(em.Z,{children:e.output_cost}),(0,s.jsx)(em.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Model Statistics (Number Requests)"}),(0,s.jsx)(ea.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Model Statistics (Latency)"}),(0,s.jsx)(ea.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})}),(0,s.jsxs)(eN.Z,{className:"h-full",children:[(0,s.jsx)(eF,{level:2,children:"Add new model"}),(0,s.jsx)(er.Z,{children:(0,s.jsxs)(J.Z,{form:p,onFinish:()=>{p.validateFields().then(e=>{k(e)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ey.Z,{value:j.toString(),children:["OpenAI","Azure OpenAI","Anthropic","Gemini (Google AI Studio)","Amazon Bedrock","OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"].map((e,l)=>(0,s.jsx)(eZ.Z,{value:e,onClick:()=>{g(e)},children:e},l))})}),(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,s.jsx)(eC.Z,{placeholder:"gpt-3.5-turbo"})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Model name your users will pass in. Also used for ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalancing."})]})})]}),(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eC.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Actual model name used for making ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"})]})})]}),"Amazon Bedrock"!=j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,s.jsx)(eC.Z,{placeholder:"sk-",type:"password"})}),("Azure OpenAI"==j||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==j)&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,s.jsx)(eC.Z,{placeholder:"https://..."})}),"Azure OpenAI"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,s.jsx)(eC.Z,{placeholder:"2023-07-01-preview"})}),"Azure OpenAI"==j&&(0,s.jsxs)(J.Z.Item,{label:"Base Model",name:"base_model",children:[(0,s.jsx)(eC.Z,{placeholder:"azure/gpt-3.5-turbo"}),(0,s.jsxs)(K.Z,{children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from ",(0,s.jsx)(eO,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})]}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:""})}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:""})}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:"us-east-1"})}),(0,s.jsx)(J.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eE.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,s.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add Model"})}),(0,s.jsx)(eT.Z,{title:"Get help on our github",children:(0,s.jsx)(eb.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]})]})]})})};let{Option:eR}=G.default;var eU=e=>{let{userID:l,accessToken:t}=e,[r]=J.Z.useForm(),[n,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[m,h]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{let e=await f(t,l,"any"),s=[];for(let l=0;l{o(!1),r.resetFields()},p=()=>{o(!1),c(null),r.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let s=await u(t,l,e);console.log("user create Response:",s),c(s.key),d.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,s.jsx)(W.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,s.jsxs)(J.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",children:(0,s.jsx)(Y.Z,{placeholder:"Enter User ID"})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"team_id",children:(0,s.jsx)(Y.Z,{placeholder:"ai_team"})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsx)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,s.jsx)(eR,{value:e,children:e},e))})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Metadata",name:"metadata",children:(0,s.jsx)(Y.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,s.jsxs)(W.Z,{title:"Save Your User",visible:n,onOk:x,onCancel:p,footer:null,children:[(0,s.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,s.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,s.jsx)("p",{children:null!=i?"API user: ".concat(i):"User being created, this might take 30s"})]})]})},eD=e=>{let{accessToken:l,token:t,keys:r,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[u,x]=(0,a.useState)(1);if((0,a.useEffect)(()=>{if(!l||!t||!n||!o)return;let e=async()=>{try{let e=await j(l,null,n,!0,u,25);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&n&&o&&e();let s=async()=>{try{let e=await N(l,null);console.log("user data response:",e),h(e)}catch(e){console.error("There was an error fetching the model data",e)}};n&&("Admin"==n||"Admin Viewer"==n)&&!m&&s()},[l,t,n,o,u]),!c||!l||!t||!n||!o)return(0,s.jsx)("div",{children:"Loading..."});let p=async e=>{try{let t=await N(l,e);console.log("user data response:",t),h(t)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,s.jsx)("div",{style:{width:"100%"},children:(0,s.jsxs)(z.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,s.jsx)(eU,{userID:o,accessToken:l}),(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{variant:"line",defaultValue:"1",children:[(0,s.jsx)(e_.Z,{value:"1",children:"Key Owners"}),(0,s.jsx)(e_.Z,{value:"2",children:"End-Users"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"User ID"}),(0,s.jsx)(eu.Z,{children:"User Role"}),(0,s.jsx)(eu.Z,{children:"User Models"}),(0,s.jsx)(eu.Z,{children:"User Spend ($ USD)"}),(0,s.jsx)(eu.Z,{children:"User Max Budget ($ USD)"})]})}),(0,s.jsx)(ed.Z,{children:c.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_id}),(0,s.jsx)(em.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,s.jsx)(em.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,s.jsx)(em.Z,{children:e.spend?e.spend:0}),(0,s.jsx)(em.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,s.jsx)(K.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,s.jsx)(ey.Z,{defaultValue:"1",className:"w-3/4",children:null==r?void 0:r.map((e,l)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>p(e.token),children:e.key_name},l)})})]})]}),(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"End User"}),(0,s.jsx)(eu.Z,{children:"Spend"}),(0,s.jsx)(eu.Z,{children:"Total Events"})]})}),(0,s.jsx)(ed.Z,{children:null==m?void 0:m.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.end_user}),(0,s.jsx)(em.Z,{children:e.total_spend}),(0,s.jsx)(em.Z,{children:e.total_events})]},l))})]})]})]})]})}),function(){if(!c)return null;let e=(u-1)*25+1,l=Math.min(25*u,c.length);return(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("div",{children:["Showing ",e," – ",l," of ",c.length]}),(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===u,onClick:()=>x(u-1),children:"← Prev"}),(0,s.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{x(u+1)},children:"Next →"})]})]})}()]})})},eL=e=>{let{teams:l,searchParams:t,accessToken:r,setTeams:n,userID:o,userRole:i}=e,[c]=J.Z.useForm(),[m]=J.Z.useForm(),{Title:h,Paragraph:u}=eb.default,[x,j]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),[Z,w]=(0,a.useState)(l?l[0]:null),[b,k]=(0,a.useState)(!1),[_,v]=(0,a.useState)(!1),[S,N]=(0,a.useState)([]),[A,C]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),E=e=>{w(e),y(!0)},M=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==r)return;let s=await F(r,e);l&&n(l.map(e=>e.team_id===t?s.data:e)),d.ZP.success("Team updated successfully"),y(!1),w(null)},R=async e=>{P(e),C(!0)},U=async()=>{if(null!=I&&null!=l&&null!=r){try{await p(r,I);let e=l.filter(e=>e.team_id!==I);n(e)}catch(e){console.error("Error deleting the team:",e)}C(!1),P(null)}};(0,a.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==r){let e=(await f(r,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,o,i]);let D=async e=>{try{if(null!=r){d.ZP.info("Creating Team");let t=await T(r,e);null!==l?n([...l,t]):n([t]),console.log("response for team create call: ".concat(t)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},q=async e=>{try{if(null!=r&&null!=l){d.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},s=await O(r,Z.team_id,t);console.log("response for team create call: ".concat(s.data));let a=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(s.data.team_id)),e.team_id===s.data.team_id));if(console.log("foundIndex: ".concat(a)),-1!==a){let e=[...l];e[a]=s.data,n(e),w(s.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(l)),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"All Teams"}),(0,s.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Team Name"}),(0,s.jsx)(eu.Z,{children:"Spend (USD)"}),(0,s.jsx)(eu.Z,{children:"Budget (USD)"}),(0,s.jsx)(eu.Z,{children:"Models"}),(0,s.jsx)(eu.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ed.Z,{children:l&&l.length>0?l.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,s.jsx)(em.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,s.jsxs)(K.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>E(e)}),(0,s.jsx)(ei.Z,{onClick:()=>R(e.team_id),icon:et.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,s.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,s.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,s.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,s.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,s.jsx)("div",{className:"sm:flex sm:items-start",children:(0,s.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,s.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,s.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{C(!1),P(null)},children:"Cancel"})]})]})]})})]})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,s.jsx)(W.Z,{title:"Create Team",visible:b,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,s.jsxs)(J.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(G.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,s.jsx)(G.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"Team Members"}),(0,s.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,s.jsx)(ey.Z,{defaultValue:"0",children:l.map((e,l)=>(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>{w(e)},children:e.team_alias},l))}):(0,s.jsxs)(u,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Member Name"}),(0,s.jsx)(eu.Z,{children:"Role"})]})}),(0,s.jsx)(ed.Z,{children:Z?Z.members_with_roles.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(em.Z,{children:e.role})]},l)):null})]})}),Z&&(0,s.jsx)(e=>{let{visible:l,onCancel:t,team:a,onSubmit:r}=e,[n]=J.Z.useForm();return(0,s.jsx)(W.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:a.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,s.jsxs)(J.Z,{form:n,onFinish:M,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(G.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,s.jsx)(G.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),w(null)},team:Z,onSubmit:M})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,s.jsx)(W.Z,{title:"Add member",visible:_,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,s.jsxs)(J.Z,{form:c,onFinish:q,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,s.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ez=e=>{let{searchParams:l,accessToken:t,showSSOBanner:r}=e,[n]=J.Z.useForm(),[o]=J.Z.useForm(),{Title:i,Paragraph:c}=eb.default,[m,h]=(0,a.useState)(""),[u,x]=(0,a.useState)(null),[p,j]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1),[Z,f]=(0,a.useState)(!1),w=["proxy_admin","proxy_admin_viewer"];(0,a.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await P(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await P(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),x(e)}})()},[t]);let b=()=>{f(!1),o.resetFields()},k=()=>{f(!1),o.resetFields()},_=e=>(0,s.jsxs)(J.Z,{form:n,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,s.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add member"})})]}),v=(e,l,t)=>(0,s.jsxs)(J.Z,{form:n,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ey.Z,{value:l,children:w.map((e,l)=>(0,s.jsx)(eZ.Z,{value:e,children:e},l))})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,s.jsx)(Y.Z,{value:t,disabled:!0})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Update role"})})]}),S=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call");let l=await M(t,e,null);console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),d.ZP.success("Refresh tab to see updated user role"),f(!1)}}catch(e){console.error("Error creating the key:",e)}},N=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call");let l=await M(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),j(!1)}}catch(e){console.error("Error creating the key:",e)}},A=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await M(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),y(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==u?void 0:u.length)),(0,s.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,s.jsx)(i,{level:4,children:"Admin Access "}),(0,s.jsxs)(c,{children:[r&&(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,s.jsx)("br",{}),(0,s.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,s.jsx)("br",{}),(0,s.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Member Name"}),(0,s.jsx)(eu.Z,{children:"Role"})]})}),(0,s.jsx)(ed.Z,{children:u?u.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(em.Z,{children:e.user_role}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>f(!0)}),(0,s.jsx)(W.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:b,onCancel:k,children:v(S,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)("div",{className:"flex justify-start",children:[(0,s.jsx)(B.Z,{className:"mr-4 mb-5",onClick:()=>y(!0),children:"+ Add admin"}),(0,s.jsx)(W.Z,{title:"Add admin",visible:g,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:_(A)}),(0,s.jsx)(B.Z,{className:"mb-5",onClick:()=>j(!0),children:"+ Add viewer"}),(0,s.jsx)(W.Z,{title:"Add viewer",visible:p,width:800,footer:null,onOk:()=>{j(!1),o.resetFields()},onCancel:()=>{j(!1),o.resetFields()},children:_(N)})]})})]})]})},eB=e=>{let{accessToken:l,userRole:t,userID:r}=e,[n,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!1),[d]=J.Z.useForm(),[m,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{l&&t&&r&&U(l,r,t).then(e=>{console.log("callbacks",e),o(e.data.success_callback)})},[l,t,r]);let u=()=>{l&&d.validateFields().then(e=>{console.log("Form values:",e),"langfuse"===e.callback?(D(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}}),o(n?[...n,e.callback]:[e.callback])):"slack"===e.callback&&(D(l,{litellm_settings:{success_callback:[e.callback]},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),o(n?[...n,e.callback]:[e.callback])),c(!1),d.resetFields(),h(null)})};return(0,s.jsxs)("div",{className:"w-full mx-4",children:[(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(er.Z,{className:"h-[15vh]",children:[(0,s.jsxs)(z.Z,{numItems:2,className:"mt-2",children:[(0,s.jsx)(L.Z,{children:(0,s.jsx)(q.Z,{children:"Logging Callbacks"})}),(0,s.jsx)(L.Z,{children:(0,s.jsx)("div",{children:n?0===n.length?(0,s.jsx)(es.Z,{children:"None"}):n.map((e,l)=>(0,s.jsx)(es.Z,{color:"sky",children:e},l)):(0,s.jsx)(es.Z,{color:"red",children:"None"})})})]}),(0,s.jsx)(L.Z,{children:(0,s.jsx)(B.Z,{size:"xs",className:"mt-2",onClick:()=>{console.log("Add callback clicked"),c(!0)},children:"Add Callback"})})]})}),(0,s.jsx)(W.Z,{title:"Add Callback",visible:i,onOk:u,width:800,onCancel:()=>{c(!1),d.resetFields(),h(null)},footer:null,children:(0,s.jsxs)(J.Z,{form:d,layout:"vertical",onFinish:u,children:[(0,s.jsx)(J.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,s.jsxs)(G.default,{onChange:e=>{h(e)},children:[(0,s.jsx)(G.default.Option,{value:"langfuse",children:"langfuse"}),(0,s.jsx)(G.default.Option,{value:"slack",children:"slack alerting"})]})}),"langfuse"===m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,s.jsx)(Y.Z.Password,{})}),(0,s.jsx)(J.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,s.jsx)(Y.Z.Password,{})})]}),"slack"===m&&(0,s.jsx)(J.Z.Item,{label:"SLACK_WEBHOOK_URL",name:"slackWebhookUrl",rules:[{required:!0,message:"Please enter the Slack webhook URL"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Save"})})]})})]})},eK=t(12968),eq=t(67951);async function eV(e,l,t,s){console.log("isLocal:",!1);let a=window.location.origin,r=new eK.ZP.OpenAI({apiKey:s,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let s of(await r.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eG=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,[o,i]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)([]),[u,x]=(0,a.useState)(void 0),[p,j]=(0,a.useState)([]);(0,a.useEffect)(()=>{l&&t&&r&&n&&(async()=>{try{let e=await f(l,n,r);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,r]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&r&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eV(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,s.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,s.jsx)(z.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,s.jsx)(er.Z,{children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)(e_.Z,{children:"Chat"}),(0,s.jsx)(e_.Z,{children:"API Reference"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)("div",{className:"sm:max-w-2xl",children:(0,s.jsxs)(z.Z,{numItems:2,children:[(0,s.jsxs)(L.Z,{children:[(0,s.jsx)(K.Z,{children:"API Key"}),(0,s.jsx)(eC.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,s.jsxs)(L.Z,{className:"mx-2",children:[(0,s.jsx)(K.Z,{children:"Select Model:"}),(0,s.jsx)(G.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,s.jsxs)(ec.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,s.jsx)(eh.Z,{children:(0,s.jsx)(ex.Z,{children:(0,s.jsx)(em.Z,{})})}),(0,s.jsx)(ed.Z,{children:m.map((e,l)=>(0,s.jsx)(ex.Z,{children:(0,s.jsx)(em.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,s.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)(eC.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,s.jsx)(B.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)(e_.Z,{children:"OpenAI Python SDK"}),(0,s.jsx)(e_.Z,{children:"LlamaIndex"}),(0,s.jsx)(e_.Z,{children:"Langchain Py"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.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 '})})]})]})})]})]})})})})},eJ=t(33509),eW=t(95781);let{Sider:eY}=eJ.default;var e$=e=>{let{setPage:l,userRole:t,defaultSelectedKey:a}=e;return"Admin Viewer"==t?(0,s.jsx)(eJ.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eY,{width:120,children:(0,s.jsxs)(eW.Z,{mode:"inline",defaultSelectedKeys:a||["4"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eW.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,s.jsx)(eJ.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eY,{width:120,children:(0,s.jsxs)(eW.Z,{mode:"inline",defaultSelectedKeys:a||["1"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eW.Z.Item,{onClick:()=>l("api-keys"),children:(0,s.jsx)(K.Z,{children:"API Keys"})},"1"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("llm-playground"),children:(0,s.jsx)(K.Z,{children:"Test Key"})},"3"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("models"),children:(0,s.jsx)(K.Z,{children:"Models"})},"2"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("teams"),children:(0,s.jsx)(K.Z,{children:"Teams"})},"6"):null,(0,s.jsx)(eW.Z.Item,{onClick:()=>l("usage"),children:(0,s.jsx)(K.Z,{children:"Usage"})},"4"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("users"),children:(0,s.jsx)(K.Z,{children:"Users"})},"5"):null,(0,s.jsx)(eW.Z.Item,{onClick:()=>l("settings"),children:(0,s.jsx)(K.Z,{children:"Integrations"})},"8"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("admin-panel"),children:(0,s.jsx)(K.Z,{children:"Admin"})},"7"):null]})})})},eH=t(67989),eX=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,o=new Date,[i,c]=(0,a.useState)([]),[d,m]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x,p]=(0,a.useState)([]),[j,g]=(0,a.useState)([]),[y,Z]=(0,a.useState)([]),[f,w]=(0,a.useState)([]),[N,I]=(0,a.useState)([]),P=new Date(o.getFullYear(),o.getMonth(),1),T=new Date(o.getFullYear(),o.getMonth()+1,0),E=O(P),F=O(T);function O(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(E)),console.log("End date is ".concat(F)),(0,a.useEffect)(()=>{l&&t&&r&&n&&(async()=>{try{if(console.log("user role: ".concat(r)),"Admin"==r||"Admin Viewer"==r){let e=await v(l);c(e);let t=(await S(l)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,10),spend:e.total_spend}));m(t);let s=(await A(l)).map(e=>({key:e.model,spend:e.total_spend}));u(s);let a=await b(l);console.log("teamSpend",a),g(a.daily_spend),w(a.teams);let r=a.total_spend_per_team;r=r.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e)),I(r);let n=await k(l);Z(n.top_10_tags)}else"App Owner"==r&&await _(l,t,r,n,E,F).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),c(l);let t=e.top_api_keys;m(t)}else{let t=(await C(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));m(t),p(function(e){let l={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[t,s]=e;""!==t&&null!=t&&"None"!=t&&(l[t]||(l[t]=0),l[t]+=s)})});let t=Object.entries(l).map(e=>{let[l,t]=e;return{user_id:l,spend:t}});t.sort((e,l)=>l.spend-e.spend);let s=t.slice(0,5);return console.log("topKeys: ".concat(Object.values(s[0]))),s}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,r,n,E,F]),(0,s.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,s.jsx)(eg,{userID:n,userRole:r,accessToken:l}),(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{className:"mt-2",children:[(0,s.jsx)(e_.Z,{children:"All Up"}),(0,s.jsx)(e_.Z,{children:"Team Based Usage"}),(0,s.jsx)(e_.Z,{children:"Tag Based Usage"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsx)(L.Z,{numColSpan:2,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Monthly Spend"}),(0,s.jsx)(ea.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top API Keys"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top Users"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top Models"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsxs)(L.Z,{numColSpan:2,children:[(0,s.jsxs)(er.Z,{className:"mb-2",children:[(0,s.jsx)(q.Z,{children:"Total Spend Per Team"}),(0,s.jsx)(eH.Z,{data:N})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Daily Spend Per Team"}),(0,s.jsx)(ea.Z,{className:"h-72",data:j,showLegend:!0,index:"date",categories:f,yAxisWidth:80,stack:!0})]})]}),(0,s.jsx)(L.Z,{numColSpan:2})]})}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,s.jsx)(L.Z,{numColSpan:2,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Spend Per Tag - Last 30 Days"}),(0,s.jsxs)(K.Z,{children:["Get Started Tracking cost per tag ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Tag"}),(0,s.jsx)(eu.Z,{children:"Spend"}),(0,s.jsx)(eu.Z,{children:"Requests"})]})}),(0,s.jsx)(ed.Z,{children:y.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.name}),(0,s.jsx)(em.Z,{children:e.value}),(0,s.jsx)(em.Z,{children:e.log_count})]},e.name))})]})]})}),(0,s.jsx)(L.Z,{numColSpan:2})]})})]})]})]})},eQ=()=>{let{Title:e,Paragraph:l}=eb.default,[t,n]=(0,a.useState)(""),[o,i]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),j=(0,r.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[Z,f]=(0,a.useState)("api-keys"),[w,b]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(y){let e=(0,ew.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),b(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),n(l),"Admin Viewer"==l&&f("usage")}else console.log("User role not defined");e.user_email?i(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?p("username_password"==e.login_method):console.log("User Email is not set ".concat(e))}}},[y]),(0,s.jsx)(a.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading..."}),children:(0,s.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,s.jsx)(c,{userID:g,userRole:t,userEmail:o,showSSOBanner:x}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,s.jsx)("div",{className:"mt-8",children:(0,s.jsx)(e$,{setPage:f,userRole:t,defaultSelectedKey:null})}),"api-keys"==Z?(0,s.jsx)(ek,{userID:g,userRole:t,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==Z?(0,s.jsx)(eM,{userID:g,userRole:t,token:y,accessToken:w}):"llm-playground"==Z?(0,s.jsx)(eG,{userID:g,userRole:t,token:y,accessToken:w}):"users"==Z?(0,s.jsx)(eD,{userID:g,userRole:t,token:y,keys:h,accessToken:w,setKeys:u}):"teams"==Z?(0,s.jsx)(eL,{teams:d,setTeams:m,searchParams:j,accessToken:w,userID:g,userRole:t}):"admin-panel"==Z?(0,s.jsx)(ez,{setTeams:m,searchParams:j,accessToken:w,showSSOBanner:x}):"settings"==Z?(0,s.jsx)(eB,{userID:g,userRole:t,accessToken:w}):(0,s.jsx)(eX,{userID:g,userRole:t,token:y,accessToken:w})]})]})})}}},function(e){e.O(0,[253,971,69,744],function(){return e(e.s=79615)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-b1c753f5772a7c45.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-b1c753f5772a7c45.js new file mode 100644 index 000000000..b9032ad85 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-b1c753f5772a7c45.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{79615:function(e,l,t){Promise.resolve().then(t.bind(t,75662))},75662:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return eQ}});var s=t(3827),a=t(64090),r=t(47907),n=t(8792),o=t(40491),i=t(65270),c=e=>{let{userID:l,userRole:t,userEmail:a,showSSOBanner:r}=e;console.log("User ID:",l),console.log("userEmail:",a),console.log("showSSOBanner:",r);let c=[{key:"1",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{children:["Role: ",t]}),(0,s.jsxs)("p",{children:["ID: ",l]})]})}];return(0,s.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,s.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,s.jsx)("div",{className:"flex flex-col items-center",children:(0,s.jsx)(n.default,{href:"/",children:(0,s.jsx)("button",{className:"text-gray-800 text-2xl py-1 rounded text-center",children:(0,s.jsx)("img",{src:"/get_image",width:200,height:200,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,s.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,s.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,s.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Request hosted proxy"})}):null,(0,s.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,s.jsx)(o.Z,{menu:{items:c},children:(0,s.jsx)(i.Z,{children:a})})})]})]})},d=t(80588);let m=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),d.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw d.ZP.error("Failed to parse metadata: "+e),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete key: "+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}},p=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete team: "+e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},j=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=arguments.length>4?arguments[4]:void 0,r=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&r&&(n="".concat(n,"?view_all=true&page=").concat(a,"&page_size=").concat(r));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw d.ZP.error(e),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},g=async e=>{try{let l=await fetch("/global/spend",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{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 t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},Z=async(e,l,t)=>{try{let l=await fetch("/model/metrics",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,l,t)=>{try{let l=await fetch("/models",{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")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{let t="/global/spend/logs";console.log("in keySpendLogsCall:",t);let s=await fetch("".concat(t,"?api_key=").concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{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}},k=async e=>{try{let l="/global/spend/tags";console.log("in tagsSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error(e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t,s,a,r)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(a,"&end_date=").concat(r):"".concat(l,"?start_date=").concat(a,"&end_date=").concat(r);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw d.ZP.error(e),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},v=async e=>{try{let l=await fetch("/global/spend/logs",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l)=>{try{l&&JSON.stringify({api_key:l});let t={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};l&&(t.body=JSON.stringify({api_key:l}));let s=await fetch("/global/spend/end_users",t);if(!s.ok){let e=await s.text();throw d.ZP.error(e),Error("Network response was not ok")}let a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},A=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{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 t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});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}},I=async e=>{try{let l="/user/get_requests";console.log("in userGetRequesedtModelsCall:",l);let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to delete key: "+e),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to get requested models:",e),e}},P=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",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 a=await s.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},T=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to create key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to update key: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw d.ZP.error("Failed to update team: "+e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member: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 a=await s.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let a=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!a.ok){let e=await a.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 a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l)=>{try{let t=await fetch("/global/predict/spend/logs",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:l})});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}},U=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{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")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},D=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});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 set callbacks:",e),e}};var L=t(10384),z=t(46453),B=t(2179),K=t(71801),q=t(42440),V=t(42308),G=t(50670),J=t(81583),W=t(77171),Y=t(42539),$=t(88707),H=t(1861);let{Option:X}=G.default;var Q=e=>{let{userID:l,team:t,userRole:r,accessToken:n,data:o,setData:i}=e,[c]=J.Z.useForm(),[m,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(null),[j,g]=(0,a.useState)(null),[y,Z]=(0,a.useState)([]),w=()=>{u(!1),c.resetFields()},b=()=>{u(!1),p(null),c.resetFields()};(0,a.useEffect)(()=>{(async()=>{try{if(null===l||null===r)return;if(null!==n){let e=(await f(n,l,r)).data.map(e=>e.id);console.log("available_model_names:",e),Z(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,r]);let k=async e=>{try{d.ZP.info("Making API Call"),u(!0);let t=await h(n,l,e);console.log("key create Response:",t),i(e=>e?[...e,t]:[t]),p(t.key),g(t.soft_budget),d.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>u(!0),children:"+ Create New Key"}),(0,s.jsx)(W.Z,{title:"Create Key",visible:m,width:800,footer:null,onOk:w,onCancel:b,children:(0,s.jsxs)(J.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:["App Owner"===r||"Admin"===r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,s.jsx)(Y.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(X,{value:"all-team-models",children:"All Team Models"},"all-team-models"),t&&t.models?t.models.includes("all-proxy-models")?y.map(e=>(0,s.jsx)(X,{value:e,children:e},e)):t.models.map(e=>(0,s.jsx)(X,{value:e,children:e},e)):y.map(e=>(0,s.jsx)(X,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,s.jsxs)(G.default,{defaultValue:null,placeholder:"n/a",children:[(0,s.jsx)(G.default.Option,{value:"24h",children:"daily"}),(0,s.jsx)(G.default.Option,{value:"30d",children:"monthly"})]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Metadata",name:"metadata",children:(0,s.jsx)(Y.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Team ID (Contact Group)",name:"team_id",children:(0,s.jsx)(Y.Z,{placeholder:"default team (create a new team)"})}),(0,s.jsx)(J.Z.Item,{label:"Description",name:"description",children:(0,s.jsx)(Y.Z.TextArea,{placeholder:"Enter description",rows:4})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create Key"})})]})}),x&&(0,s.jsx)(W.Z,{visible:m,onOk:w,onCancel:b,footer:null,children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 w-full",children:[(0,s.jsx)(q.Z,{children:"Save your Key"}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,s.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:null!=x?(0,s.jsxs)("div",{children:[(0,s.jsx)(K.Z,{className:"mt-3",children:"API Key:"}),(0,s.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,s.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:x})}),(0,s.jsx)(V.CopyToClipboard,{text:x,onCopy:()=>{d.ZP.success("API Key copied to clipboard")},children:(0,s.jsx)(B.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,s.jsx)(K.Z,{children:"Key being created, this might take 30s"})})]})})]})},ee=t(9454),el=t(98941),et=t(33393),es=t(5),ea=t(9853),er=t(13810),en=t(39290),eo=t(66952),ei=t(61244),ec=t(10827),ed=t(3851),em=t(2044),eh=t(64167),eu=t(74480),ex=t(7178);let{Option:ep}=G.default;var ej=e=>{let{userID:l,userRole:t,accessToken:r,selectedTeam:n,data:o,setData:i}=e,[c,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[p,j]=(0,a.useState)(null),[g,y]=a.useState(null),[Z,b]=(0,a.useState)(null),[k,_]=(0,a.useState)(null),[v,S]=(0,a.useState)(""),[N,A]=(0,a.useState)(!1),[C,I]=(0,a.useState)(null),[P,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==r&&null!==t){let e=(await f(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),T(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let F=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),I(e),A(!0)},O=async e=>{if(null==r)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await E(r,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),d.ZP.success("Key updated successfully"),A(!1),I(null)},M=async e=>{try{if(null==r||null==e)return;console.log("accessToken: ".concat(r,"; token: ").concat(e.token));let l=await w(r,e.token);console.log("Response:",l),_(l);try{let e=await R(r,l);console.log("Response2:",e);let t=[...l,...e.response];_(t),S(e.predicted_spend),console.log("Combined Data:",t)}catch(e){console.error("There was an error fetching the predicted data",e)}}catch(e){console.error("There was an error fetching the data",e)}};(0,a.useEffect)(()=>{M(Z)},[Z]);let U=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),u(!0))},D=async()=>{if(null!=p&&null!=o){try{await x(r,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}u(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,s.jsxs)("div",{children:[(0,s.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Key Alias"}),(0,s.jsx)(eu.Z,{children:"Secret Key"}),(0,s.jsx)(eu.Z,{children:"Spend (USD)"}),(0,s.jsx)(eu.Z,{children:"Budget (USD)"}),(0,s.jsx)(eu.Z,{children:"Models"}),(0,s.jsx)(eu.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ed.Z,{children:o.map(e=>(console.log(e),"litellm-dashboard"===e.team_id||n&&e.team_id!=n.team_id)?null:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,s.jsx)(K.Z,{children:e.key_alias}):(0,s.jsx)(K.Z,{children:"Not Set"})}),(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:e.key_name})}),(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,s.jsx)(em.Z,{children:null!=e.max_budget?(0,s.jsx)(K.Z,{children:e.max_budget}):(0,s.jsx)(K.Z,{children:"Unlimited"})}),(0,s.jsx)(em.Z,{children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(s.Fragment,{children:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Team Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Team Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,s.jsx)(em.Z,{children:(0,s.jsxs)(K.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{onClick:()=>{b(e),y(e.id)},icon:ee.Z,size:"sm"}),(0,s.jsx)(en.Z,{open:null!==g,onClose:()=>{y(null),b(null)},children:(0,s.jsx)(eo.Z,{children:Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3",children:[(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(Z.spend).toFixed(4)}catch(e){return Z.spend}})()})})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.max_budget?(0,s.jsx)(s.Fragment,{children:Z.max_budget}):(0,s.jsx)(s.Fragment,{children:"Unlimited"})})})]},e.name),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,s.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,s.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=Z.expires?(0,s.jsx)(s.Fragment,{children:new Date(Z.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,s.jsx)(s.Fragment,{children:"Never"})})})]},e.name)]}),(0,s.jsx)(er.Z,{className:"mt-6 mb-6",children:k&&(0,s.jsx)(ea.Z,{className:"mt-6",data:k,colors:["blue","amber"],index:"date",categories:["spend","predicted_spend"],yAxisWidth:80})}),(0,s.jsx)(q.Z,{children:"Metadata"}),(0,s.jsx)(K.Z,{children:JSON.stringify(Z.metadata)}),(0,s.jsx)(B.Z,{variant:"light",className:"mx-auto flex items-center",onClick:()=>{y(null),b(null)},children:"Close"})]})})}),(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>F(e)}),(0,s.jsx)(ei.Z,{onClick:()=>U(e),icon:et.Z,size:"sm"})]})]},e.token))})]}),h&&(0,s.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,s.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,s.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,s.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,s.jsx)("div",{className:"sm:flex sm:items-start",children:(0,s.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,s.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,s.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.Z,{onClick:D,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{u(!1),j(null)},children:"Cancel"})]})]})]})})]}),C&&(0,s.jsx)(e=>{let{visible:l,onCancel:t,token:a,onSubmit:r}=e,[o]=J.Z.useForm();return console.log("in edit key modal:",a),console.log("in edit key modal, team:",n),(0,s.jsx)(W.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,s.jsxs)(J.Z,{form:o,onFinish:O,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(ep,{value:"all-team-models",children:"All Team Models"},"all-team-models"),n&&n.models?n.models.includes("all-proxy-models")?P.filter(e=>"all-proxy-models"!==e).map(e=>(0,s.jsx)(ep,{value:e,children:e},e)):n.models.map(e=>(0,s.jsx)(ep,{value:e,children:e},e)):P.map(e=>(0,s.jsx)(ep,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==n?void 0:n.max_budget)!==null&&(null==n?void 0:n.max_budget)!==void 0?null==n?void 0:n.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&n&&null!==n.max_budget&&l>n.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(n.max_budget))}}],children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"token",name:"token",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:N,onCancel:()=>{A(!1),I(null)},token:C,onSubmit:O})]})},eg=e=>{let{userID:l,userRole:t,accessToken:r,userSpend:n}=e;console.log("userSpend: ".concat(n));let[o,i]=(0,a.useState)(null!==n?n:0),[c,d]=(0,a.useState)(0);(0,a.useEffect)(()=>{(async()=>{if(r&&l&&t&&"Admin"===t&&null==n)try{let e=await g(r);e&&(e.spend?i(e.spend):i(0),e.max_budget?d(e.max_budget):d(0))}catch(e){console.error("Error fetching global spend data:",e)}})()},[t,r]),(0,a.useEffect)(()=>{null!==n&&i(n)},[n]);let m=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:"Total Spend "}),(0,s.jsxs)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",m]})]})},ey=t(55901),eZ=t(27166),ef=e=>{let{teams:l,setSelectedTeam:t}=e,r={models:[],team_id:null,team_alias:"Default Team"},[n,o]=(0,a.useState)(r),i=l?[...l,r]:[r];return(0,s.jsxs)("div",{className:"mt-5 mb-5",children:[(0,s.jsx)(q.Z,{children:"Select Team"}),(0,s.jsx)(K.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,s.jsxs)(K.Z,{className:"mt-3 mb-3",children:[(0,s.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),i&&i.length>0?(0,s.jsx)(ey.Z,{defaultValue:"0",children:i.map((e,l)=>(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,s.jsxs)(K.Z,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]})},ew=t(37963),eb=t(36083);console.log("isLocal:",!1);var ek=e=>{let{userID:l,userRole:t,teams:n,keys:o,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,a.useState)(null),p=(0,r.useSearchParams)();p.get("viewSpend"),(0,r.useRouter)();let y=p.get("token"),[Z,w]=(0,a.useState)(null),[b,k]=(0,a.useState)(null),[_,v]=(0,a.useState)([]),[S,N]=(0,a.useState)(n?n[0]:null);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,a.useEffect)(()=>{if(y){let e=(0,ew.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),w(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&Z&&t&&!o&&!u){let e=sessionStorage.getItem("userModels"+l);e?v(JSON.parse(e)):(async()=>{try{let e=await j(Z,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await g(Z);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams),N(e.teams?e.teams[0]:null),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let s=(await f(Z,l,t)).data.map(e=>e.id);console.log("available_model_names:",s),v(s),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(s))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,Z,o,t]),(0,a.useEffect)(()=>{if(null!==o&&null!==S){let e=0;for(let l of o)console.log("key in team keys: ".concat(l.team_id)),console.log("selected team: ".concat(S.team_id)),null!==l.team_id&&l.team_id===S.team_id&&(e+=l.spend);k(e)}},[S]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==Z)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",S),console.log("teamSpend: ".concat(b)),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(eg,{userID:l,userRole:t,accessToken:Z,userSpend:b}),(0,s.jsx)(ej,{userID:l,userRole:t,accessToken:Z,selectedTeam:S||null,data:o,setData:h}),(0,s.jsx)(Q,{userID:l,team:S||null,userRole:t,accessToken:Z,data:o,setData:h},S?S.team_id:null),(0,s.jsx)(ef,{teams:n,setSelectedTeam:N})]})})})},e_=t(92836),ev=t(26734),eS=t(41608),eN=t(32126),eA=t(23682),eC=t(52273),eI=t(38302),eP=t(28683),eT=t(1460),eE=t(78578);let{Title:eF,Link:eO}=eb.default;var eM=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,[o,i]=(0,a.useState)({data:[]}),[c,h]=(0,a.useState)([]),[u,x]=(0,a.useState)([]),[p]=J.Z.useForm(),[j,g]=(0,a.useState)("OpenAI");if((0,a.useEffect)(()=>{if(!l||!t||!r||!n)return;let e=async()=>{try{let e=await y(l,n,r);console.log("Model data response:",e.data),i(e);let t=await Z(l,n,r);if(console.log("Model metrics response:",t),h(t),"Admin"===r&&l){let e=await I(l);console.log("Pending Requests:",u),x(e.requests||[])}}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&n&&e()},[l,t,r,n]),!o||!l||!t||!r||!n)return(0,s.jsx)("div",{children:"Loading..."});let f=[];for(let e=0;e{let[l]=e;return"model"!==l&&"api_base"!==l}))),o.data[e].provider=r,o.data[e].input_cost=n,o.data[e].output_cost=i,o.data[e].max_tokens=c,o.data[e].api_base=null==l?void 0:null===(b=l.litellm_params)||void 0===b?void 0:b.api_base,o.data[e].cleanedLitellmParams=d,f.push(l.model_name),console.log(o.data[e])}if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let k=async e=>{try{let t={},s={},a="";for(let[l,r]of Object.entries(e))if("model_name"==l&&(a=r),("api_key"===l||"model"===l||"api_base"===l||"api_version"===l||l.startsWith("aws_"))&&(t[l]=r),"base_model"===l&&(s[l]=r),"litellm_extra_params"==l){console.log("litellm_extra_params:",r);let e={};if(r&&void 0!=r){try{e=JSON.parse(r)}catch(e){throw d.ZP.error("Failed to parse LiteLLM Extra Params: "+e),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}let r={model_name:a,litellm_params:t,model_info:s},n=await m(l,r);p.resetFields(),console.log("response for model create call: ".concat(n.data))}catch(e){d.ZP.error("Failed to create model: "+e)}};return console.log("selectedProvider: ".concat(j)),(0,s.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,s.jsxs)(ev.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(eS.Z,{className:"mt-2",children:[(0,s.jsx)(e_.Z,{children:"All Models"}),(0,s.jsx)(e_.Z,{children:"Add Model"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{children:[(0,s.jsx)(er.Z,{children:(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Model Name "}),(0,s.jsx)(eu.Z,{children:"Provider"}),"Admin"===r&&(0,s.jsx)(eu.Z,{children:"API Base"}),(0,s.jsx)(eu.Z,{children:"Extra litellm Params"}),(0,s.jsx)(eu.Z,{children:"Input Price per token ($)"}),(0,s.jsx)(eu.Z,{children:"Output Price per token ($)"}),(0,s.jsx)(eu.Z,{children:"Max Tokens"})]})}),(0,s.jsx)(ed.Z,{children:o.data.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:(0,s.jsx)(K.Z,{children:e.model_name})}),(0,s.jsx)(em.Z,{children:e.provider}),"Admin"===r&&(0,s.jsx)(em.Z,{children:e.api_base}),(0,s.jsx)(em.Z,{children:(0,s.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})}),(0,s.jsx)(em.Z,{children:e.input_cost}),(0,s.jsx)(em.Z,{children:e.output_cost}),(0,s.jsx)(em.Z,{children:e.max_tokens})]},e.model_name))})]})}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Model Statistics (Number Requests)"}),(0,s.jsx)(ea.Z,{data:c,index:"model",categories:["num_requests"],colors:["blue"],yAxisWidth:400,layout:"vertical",tickGap:5})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Model Statistics (Latency)"}),(0,s.jsx)(ea.Z,{data:c,index:"model",categories:["avg_latency_seconds"],colors:["red"],yAxisWidth:400,layout:"vertical",tickGap:5})]})]})}),(0,s.jsxs)(eN.Z,{className:"h-full",children:[(0,s.jsx)(eF,{level:2,children:"Add new model"}),(0,s.jsx)(er.Z,{children:(0,s.jsxs)(J.Z,{form:p,onFinish:()=>{p.validateFields().then(e=>{k(e)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ey.Z,{value:j.toString(),children:["OpenAI","Azure OpenAI","Anthropic","Gemini (Google AI Studio)","Amazon Bedrock","OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"].map((e,l)=>(0,s.jsx)(eZ.Z,{value:e,onClick:()=>{g(e)},children:e},l))})}),(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,s.jsx)(eC.Z,{placeholder:"gpt-3.5-turbo"})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Model name your users will pass in. Also used for ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalancing."})]})})]}),(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eC.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Actual model name used for making ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"})]})})]}),"Amazon Bedrock"!=j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,s.jsx)(eC.Z,{placeholder:"sk-",type:"password"})}),("Azure OpenAI"==j||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==j)&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,s.jsx)(eC.Z,{placeholder:"https://..."})}),"Azure OpenAI"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,s.jsx)(eC.Z,{placeholder:"2023-07-01-preview"})}),"Azure OpenAI"==j&&(0,s.jsxs)(J.Z.Item,{label:"Base Model",name:"base_model",children:[(0,s.jsx)(eC.Z,{placeholder:"azure/gpt-3.5-turbo"}),(0,s.jsxs)(K.Z,{children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from ",(0,s.jsx)(eO,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})]}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:""})}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:""})}),"Amazon Bedrock"==j&&(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,s.jsx)(eC.Z,{placeholder:"us-east-1"})}),(0,s.jsx)(J.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,s.jsx)(eE.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,s.jsxs)(eI.Z,{children:[(0,s.jsx)(eP.Z,{span:10}),(0,s.jsx)(eP.Z,{span:10,children:(0,s.jsxs)(K.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params ",(0,s.jsx)(eO,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,s.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add Model"})}),(0,s.jsx)(eT.Z,{title:"Get help on our github",children:(0,s.jsx)(eb.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]})]})]})})};let{Option:eR}=G.default;var eU=e=>{let{userID:l,accessToken:t}=e,[r]=J.Z.useForm(),[n,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[m,h]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{try{let e=await f(t,l,"any"),s=[];for(let l=0;l{o(!1),r.resetFields()},p=()=>{o(!1),c(null),r.resetFields()},j=async e=>{try{d.ZP.info("Making API Call"),o(!0),console.log("formValues in create user:",e);let s=await u(t,l,e);console.log("user create Response:",s),c(s.key),d.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>o(!0),children:"+ Create New User"}),(0,s.jsx)(W.Z,{title:"Create User",visible:n,width:800,footer:null,onOk:x,onCancel:p,children:(0,s.jsxs)(J.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",children:(0,s.jsx)(Y.Z,{placeholder:"Enter User ID"})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"team_id",children:(0,s.jsx)(Y.Z,{placeholder:"ai_team"})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsx)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:m.map(e=>(0,s.jsx)(eR,{value:e,children:e},e))})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Duration (eg: 30s, 30h, 30d)",name:"duration",children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Metadata",name:"metadata",children:(0,s.jsx)(Y.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create User"})})]})}),i&&(0,s.jsxs)(W.Z,{title:"Save Your User",visible:n,onOk:x,onCancel:p,footer:null,children:[(0,s.jsxs)("p",{children:["Please save this secret user somewhere safe and accessible. For security reasons, ",(0,s.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret user, you will need to generate a new one."]}),(0,s.jsx)("p",{children:null!=i?"API user: ".concat(i):"User being created, this might take 30s"})]})]})},eD=e=>{let{accessToken:l,token:t,keys:r,userRole:n,userID:o,setKeys:i}=e,[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[u,x]=(0,a.useState)(1);if((0,a.useEffect)(()=>{if(!l||!t||!n||!o)return;let e=async()=>{try{let e=await j(l,null,n,!0,u,25);console.log("user data response:",e),d(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&n&&o&&e();let s=async()=>{try{let e=await N(l,null);console.log("user data response:",e),h(e)}catch(e){console.error("There was an error fetching the model data",e)}};n&&("Admin"==n||"Admin Viewer"==n)&&!m&&s()},[l,t,n,o,u]),!c||!l||!t||!n||!o)return(0,s.jsx)("div",{children:"Loading..."});let p=async e=>{try{let t=await N(l,e);console.log("user data response:",t),h(t)}catch(e){console.error("There was an error fetching the model data",e)}};return(0,s.jsx)("div",{style:{width:"100%"},children:(0,s.jsxs)(z.Z,{className:"gap-2 p-2 h-[75vh] w-full mt-8",children:[(0,s.jsx)(eU,{userID:o,accessToken:l}),(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4",children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{variant:"line",defaultValue:"1",children:[(0,s.jsx)(e_.Z,{value:"1",children:"Key Owners"}),(0,s.jsx)(e_.Z,{value:"2",children:"End-Users"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(ec.Z,{className:"mt-5",children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"User ID"}),(0,s.jsx)(eu.Z,{children:"User Role"}),(0,s.jsx)(eu.Z,{children:"User Models"}),(0,s.jsx)(eu.Z,{children:"User Spend ($ USD)"}),(0,s.jsx)(eu.Z,{children:"User Max Budget ($ USD)"})]})}),(0,s.jsx)(ed.Z,{children:c.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_id}),(0,s.jsx)(em.Z,{children:e.user_role?e.user_role:"app_owner"}),(0,s.jsx)(em.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,s.jsx)(em.Z,{children:e.spend?e.spend:0}),(0,s.jsx)(em.Z,{children:e.max_budget?e.max_budget:"Unlimited"})]},e.user_id))})]})}),(0,s.jsxs)(eN.Z,{children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("div",{className:"flex-1 flex justify-between items-center",children:[(0,s.jsx)(K.Z,{className:"w-1/4 mr-2 text-right",children:"Key"}),(0,s.jsx)(ey.Z,{defaultValue:"1",className:"w-3/4",children:null==r?void 0:r.map((e,l)=>{if(e&&null!==e.key_name&&e.key_name.length>0)return(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>p(e.token),children:e.key_name},l)})})]})]}),(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"End User"}),(0,s.jsx)(eu.Z,{children:"Spend"}),(0,s.jsx)(eu.Z,{children:"Total Events"})]})}),(0,s.jsx)(ed.Z,{children:null==m?void 0:m.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.end_user}),(0,s.jsx)(em.Z,{children:e.total_spend}),(0,s.jsx)(em.Z,{children:e.total_events})]},l))})]})]})]})]})}),function(){if(!c)return null;let e=(u-1)*25+1,l=Math.min(25*u,c.length);return(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("div",{children:["Showing ",e," – ",l," of ",c.length]}),(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:1===u,onClick:()=>x(u-1),children:"← Prev"}),(0,s.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{x(u+1)},children:"Next →"})]})]})}()]})})},eL=e=>{let{teams:l,searchParams:t,accessToken:r,setTeams:n,userID:o,userRole:i}=e,[c]=J.Z.useForm(),[m]=J.Z.useForm(),{Title:h,Paragraph:u}=eb.default,[x,j]=(0,a.useState)(""),[g,y]=(0,a.useState)(!1),[Z,w]=(0,a.useState)(l?l[0]:null),[b,k]=(0,a.useState)(!1),[_,v]=(0,a.useState)(!1),[S,N]=(0,a.useState)([]),[A,C]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),E=e=>{w(e),y(!0)},M=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==r)return;let s=await F(r,e);l&&n(l.map(e=>e.team_id===t?s.data:e)),d.ZP.success("Team updated successfully"),y(!1),w(null)},R=async e=>{P(e),C(!0)},U=async()=>{if(null!=I&&null!=l&&null!=r){try{await p(r,I);let e=l.filter(e=>e.team_id!==I);n(e)}catch(e){console.error("Error deleting the team:",e)}C(!1),P(null)}};(0,a.useEffect)(()=>{(async()=>{try{if(null===o||null===i)return;if(null!==r){let e=(await f(r,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,o,i]);let D=async e=>{try{if(null!=r){d.ZP.info("Creating Team");let t=await T(r,e);null!==l?n([...l,t]):n([t]),console.log("response for team create call: ".concat(t)),d.ZP.success("Team created"),k(!1)}}catch(e){console.error("Error creating the team:",e),d.ZP.error("Error creating the team: "+e)}},q=async e=>{try{if(null!=r&&null!=l){d.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},s=await O(r,Z.team_id,t);console.log("response for team create call: ".concat(s.data));let a=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(s.data.team_id)),e.team_id===s.data.team_id));if(console.log("foundIndex: ".concat(a)),-1!==a){let e=[...l];e[a]=s.data,n(e),w(s.data)}v(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(l)),(0,s.jsx)("div",{className:"w-full mx-4",children:(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"All Teams"}),(0,s.jsxs)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Team Name"}),(0,s.jsx)(eu.Z,{children:"Spend (USD)"}),(0,s.jsx)(eu.Z,{children:"Budget (USD)"}),(0,s.jsx)(eu.Z,{children:"Models"}),(0,s.jsx)(eu.Z,{children:"TPM / RPM Limits"})]})}),(0,s.jsx)(ed.Z,{children:l&&l.length>0?l.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,s.jsx)(em.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(K.Z,{children:"All Proxy Models"})},l):(0,s.jsx)(es.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,s.jsx)(K.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,s.jsx)(em.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,s.jsxs)(K.Z,{children:["TPM:"," ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,s.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>E(e)}),(0,s.jsx)(ei.Z,{onClick:()=>R(e.team_id),icon:et.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,s.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,s.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,s.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,s.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,s.jsx)("div",{className:"sm:flex sm:items-start",children:(0,s.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,s.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,s.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(B.Z,{onClick:()=>{C(!1),P(null)},children:"Cancel"})]})]})]})})]})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto",onClick:()=>k(!0),children:"+ Create New Team"}),(0,s.jsx)(W.Z,{title:"Create Team",visible:b,width:800,footer:null,onOk:()=>{k(!1),c.resetFields()},onCancel:()=>{k(!1),c.resetFields()},children:(0,s.jsxs)(J.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(G.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,s.jsx)(G.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(h,{level:4,children:"Team Members"}),(0,s.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,s.jsx)(ey.Z,{defaultValue:"0",children:l.map((e,l)=>(0,s.jsx)(eZ.Z,{value:String(l),onClick:()=>{w(e)},children:e.team_alias},l))}):(0,s.jsxs)(u,{children:["No team created. ",(0,s.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Member Name"}),(0,s.jsx)(eu.Z,{children:"Role"})]})}),(0,s.jsx)(ed.Z,{children:Z?Z.members_with_roles.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(em.Z,{children:e.role})]},l)):null})]})}),Z&&(0,s.jsx)(e=>{let{visible:l,onCancel:t,team:a,onSubmit:r}=e,[n]=J.Z.useForm();return(0,s.jsx)(W.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:a.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,s.jsxs)(J.Z,{form:n,onFinish:M,initialValues:a,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)(J.Z.Item,{label:"Models",name:"models",children:(0,s.jsxs)(G.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(G.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,s.jsx)(G.default.Option,{value:e,children:e},e))]})}),(0,s.jsx)(J.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)($.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(J.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)($.Z,{step:1,width:400})}),(0,s.jsx)(J.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:g,onCancel:()=>{y(!1),w(null)},team:Z,onSubmit:M})]}),(0,s.jsxs)(L.Z,{numColSpan:1,children:[(0,s.jsx)(B.Z,{className:"mx-auto mb-5",onClick:()=>v(!0),children:"+ Add member"}),(0,s.jsx)(W.Z,{title:"Add member",visible:_,width:800,footer:null,onOk:()=>{v(!1),m.resetFields()},onCancel:()=>{v(!1),m.resetFields()},children:(0,s.jsxs)(J.Z,{form:c,onFinish:q,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,s.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ez=e=>{let{searchParams:l,accessToken:t,showSSOBanner:r}=e,[n]=J.Z.useForm(),[o]=J.Z.useForm(),{Title:i,Paragraph:c}=eb.default,[m,h]=(0,a.useState)(""),[u,x]=(0,a.useState)(null),[p,j]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1),[Z,f]=(0,a.useState)(!1),w=["proxy_admin","proxy_admin_viewer"];(0,a.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await P(t,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let s=await P(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),x(e)}})()},[t]);let b=()=>{f(!1),o.resetFields()},k=()=>{f(!1),o.resetFields()},_=e=>(0,s.jsxs)(J.Z,{form:n,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,s.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,s.jsx)(J.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,s.jsx)(Y.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Add member"})})]}),v=(e,l,t)=>(0,s.jsxs)(J.Z,{form:n,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ey.Z,{value:l,children:w.map((e,l)=>(0,s.jsx)(eZ.Z,{value:e,children:e},l))})}),(0,s.jsx)(J.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,s.jsx)(Y.Z,{value:t,disabled:!0})})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Update role"})})]}),S=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call");let l=await M(t,e,null);console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),d.ZP.success("Refresh tab to see updated user role"),f(!1)}}catch(e){console.error("Error creating the key:",e)}},N=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call");let l=await M(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),j(!1)}}catch(e){console.error("Error creating the key:",e)}},A=async e=>{try{if(null!=t&&null!=u){d.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await M(t,e,"proxy_admin");console.log("response for team create call: ".concat(l));let s=u.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(s)),-1==s&&(console.log("updates admin with new user"),u.push(l),x(u)),y(!1)}}catch(e){console.error("Error creating the key:",e)}};return console.log("admins: ".concat(null==u?void 0:u.length)),(0,s.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,s.jsx)(i,{level:4,children:"Admin Access "}),(0,s.jsxs)(c,{children:[r&&(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,s.jsx)("br",{}),(0,s.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,s.jsx)("br",{}),(0,s.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,s.jsxs)(z.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsx)(er.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Member Name"}),(0,s.jsx)(eu.Z,{children:"Role"})]})}),(0,s.jsx)(ed.Z,{children:u?u.map((e,l)=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,s.jsx)(em.Z,{children:e.user_role}),(0,s.jsxs)(em.Z,{children:[(0,s.jsx)(ei.Z,{icon:el.Z,size:"sm",onClick:()=>f(!0)}),(0,s.jsx)(W.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:b,onCancel:k,children:v(S,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)("div",{className:"flex justify-start",children:[(0,s.jsx)(B.Z,{className:"mr-4 mb-5",onClick:()=>y(!0),children:"+ Add admin"}),(0,s.jsx)(W.Z,{title:"Add admin",visible:g,width:800,footer:null,onOk:()=>{y(!1),o.resetFields()},onCancel:()=>{y(!1),o.resetFields()},children:_(A)}),(0,s.jsx)(B.Z,{className:"mb-5",onClick:()=>j(!0),children:"+ Add viewer"}),(0,s.jsx)(W.Z,{title:"Add viewer",visible:p,width:800,footer:null,onOk:()=>{j(!1),o.resetFields()},onCancel:()=>{j(!1),o.resetFields()},children:_(N)})]})})]})]})},eB=e=>{let{accessToken:l,userRole:t,userID:r}=e,[n,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(!1),[d]=J.Z.useForm(),[m,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{l&&t&&r&&U(l,r,t).then(e=>{console.log("callbacks",e),o(e.data.success_callback)})},[l,t,r]);let u=()=>{l&&d.validateFields().then(e=>{console.log("Form values:",e),"langfuse"===e.callback?(D(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}}),o(n?[...n,e.callback]:[e.callback])):"slack"===e.callback&&(D(l,{litellm_settings:{success_callback:[e.callback]},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),o(n?[...n,e.callback]:[e.callback])),c(!1),d.resetFields(),h(null)})};return(0,s.jsxs)("div",{className:"w-full mx-4",children:[(0,s.jsx)(z.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,s.jsxs)(er.Z,{className:"h-[15vh]",children:[(0,s.jsxs)(z.Z,{numItems:2,className:"mt-2",children:[(0,s.jsx)(L.Z,{children:(0,s.jsx)(q.Z,{children:"Logging Callbacks"})}),(0,s.jsx)(L.Z,{children:(0,s.jsx)("div",{children:n?0===n.length?(0,s.jsx)(es.Z,{children:"None"}):n.map((e,l)=>(0,s.jsx)(es.Z,{color:"sky",children:e},l)):(0,s.jsx)(es.Z,{color:"red",children:"None"})})})]}),(0,s.jsx)(L.Z,{children:(0,s.jsx)(B.Z,{size:"xs",className:"mt-2",onClick:()=>{console.log("Add callback clicked"),c(!0)},children:"Add Callback"})})]})}),(0,s.jsx)(W.Z,{title:"Add Callback",visible:i,onOk:u,width:800,onCancel:()=>{c(!1),d.resetFields(),h(null)},footer:null,children:(0,s.jsxs)(J.Z,{form:d,layout:"vertical",onFinish:u,children:[(0,s.jsx)(J.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,s.jsxs)(G.default,{onChange:e=>{h(e)},children:[(0,s.jsx)(G.default.Option,{value:"langfuse",children:"langfuse"}),(0,s.jsx)(G.default.Option,{value:"slack",children:"slack alerting"})]})}),"langfuse"===m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(J.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,s.jsx)(Y.Z.Password,{})}),(0,s.jsx)(J.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,s.jsx)(Y.Z.Password,{})})]}),"slack"===m&&(0,s.jsx)(J.Z.Item,{label:"SLACK_WEBHOOK_URL",name:"slackWebhookUrl",rules:[{required:!0,message:"Please enter the Slack webhook URL"}],children:(0,s.jsx)(Y.Z,{})}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(H.ZP,{htmlType:"submit",children:"Save"})})]})})]})},eK=t(12968),eq=t(67951);async function eV(e,l,t,s){console.log("isLocal:",!1);let a=window.location.origin,r=new eK.ZP.OpenAI({apiKey:s,baseURL:a,dangerouslyAllowBrowser:!0});try{for await(let s of(await r.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){d.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e))}}var eG=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,[o,i]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)([]),[u,x]=(0,a.useState)(void 0),[p,j]=(0,a.useState)([]);(0,a.useEffect)(()=>{l&&t&&r&&n&&(async()=>{try{let e=await f(l,n,r);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,r]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&r&&n){h(e=>[...e,{role:"user",content:c}]);try{u&&await eV(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(r&&"Admin Viewer"==r){let{Title:e,Paragraph:l}=eb.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,s.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,s.jsx)(z.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,s.jsx)(er.Z,{children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)(e_.Z,{children:"Chat"}),(0,s.jsx)(e_.Z,{children:"API Reference"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsxs)(eN.Z,{children:[(0,s.jsx)("div",{className:"sm:max-w-2xl",children:(0,s.jsxs)(z.Z,{numItems:2,children:[(0,s.jsxs)(L.Z,{children:[(0,s.jsx)(K.Z,{children:"API Key"}),(0,s.jsx)(eC.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,s.jsxs)(L.Z,{className:"mx-2",children:[(0,s.jsx)(K.Z,{children:"Select Model:"}),(0,s.jsx)(G.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,s.jsxs)(ec.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,s.jsx)(eh.Z,{children:(0,s.jsx)(ex.Z,{children:(0,s.jsx)(em.Z,{})})}),(0,s.jsx)(ed.Z,{children:m.map((e,l)=>(0,s.jsx)(ex.Z,{children:(0,s.jsx)(em.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,s.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)(eC.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,s.jsx)(B.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{children:[(0,s.jsx)(e_.Z,{children:"OpenAI Python SDK"}),(0,s.jsx)(e_.Z,{children:"LlamaIndex"}),(0,s.jsx)(e_.Z,{children:"Langchain Py"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # proxy base url\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to use from Models Tab\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ],\n extra_body={\n "metadata": {\n "generation_name": "ishaan-generation-openai-client",\n "generation_id": "openai-client-gen-id22",\n "trace_id": "openai-client-trace-id22",\n "trace_user_id": "openai-client-user-id2"\n }\n }\n)\n\nprint(response)\n '})}),(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,s.jsx)(eN.Z,{children:(0,s.jsx)(eq.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 '})})]})]})})]})]})})})})},eJ=t(33509),eW=t(95781);let{Sider:eY}=eJ.default;var e$=e=>{let{setPage:l,userRole:t,defaultSelectedKey:a}=e;return"Admin Viewer"==t?(0,s.jsx)(eJ.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eY,{width:120,children:(0,s.jsxs)(eW.Z,{mode:"inline",defaultSelectedKeys:a||["4"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eW.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,s.jsx)(eJ.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,s.jsx)(eY,{width:120,children:(0,s.jsxs)(eW.Z,{mode:"inline",defaultSelectedKeys:a||["1"],style:{height:"100%",borderRight:0},children:[(0,s.jsx)(eW.Z.Item,{onClick:()=>l("api-keys"),children:(0,s.jsx)(K.Z,{children:"API Keys"})},"1"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("llm-playground"),children:(0,s.jsx)(K.Z,{children:"Test Key"})},"3"),(0,s.jsx)(eW.Z.Item,{onClick:()=>l("models"),children:(0,s.jsx)(K.Z,{children:"Models"})},"2"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("teams"),children:(0,s.jsx)(K.Z,{children:"Teams"})},"6"):null,(0,s.jsx)(eW.Z.Item,{onClick:()=>l("usage"),children:(0,s.jsx)(K.Z,{children:"Usage"})},"4"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("users"),children:(0,s.jsx)(K.Z,{children:"Users"})},"5"):null,(0,s.jsx)(eW.Z.Item,{onClick:()=>l("settings"),children:(0,s.jsx)(K.Z,{children:"Integrations"})},"8"),"Admin"==t?(0,s.jsx)(eW.Z.Item,{onClick:()=>l("admin-panel"),children:(0,s.jsx)(K.Z,{children:"Admin"})},"7"):null]})})})},eH=t(67989),eX=e=>{let{accessToken:l,token:t,userRole:r,userID:n}=e,o=new Date,[i,c]=(0,a.useState)([]),[d,m]=(0,a.useState)([]),[h,u]=(0,a.useState)([]),[x,p]=(0,a.useState)([]),[j,g]=(0,a.useState)([]),[y,Z]=(0,a.useState)([]),[f,w]=(0,a.useState)([]),[N,I]=(0,a.useState)([]),P=new Date(o.getFullYear(),o.getMonth(),1),T=new Date(o.getFullYear(),o.getMonth()+1,0),E=O(P),F=O(T);function O(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(E)),console.log("End date is ".concat(F)),(0,a.useEffect)(()=>{l&&t&&r&&n&&(async()=>{try{if(console.log("user role: ".concat(r)),"Admin"==r||"Admin Viewer"==r){let e=await v(l);c(e);let t=(await S(l)).map(e=>({key:(e.key_name||e.key_alias||e.api_key).substring(0,10),spend:e.total_spend}));m(t);let s=(await A(l)).map(e=>({key:e.model,spend:e.total_spend}));u(s);let a=await b(l);console.log("teamSpend",a),g(a.daily_spend),w(a.teams);let r=a.total_spend_per_team;r=r.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e)),I(r);let n=await k(l);Z(n.top_10_tags)}else"App Owner"==r&&await _(l,t,r,n,E,F).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),c(l);let t=e.top_api_keys;m(t)}else{let t=(await C(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));m(t),p(function(e){let l={};e.forEach(e=>{Object.entries(e.users).forEach(e=>{let[t,s]=e;""!==t&&null!=t&&"None"!=t&&(l[t]||(l[t]=0),l[t]+=s)})});let t=Object.entries(l).map(e=>{let[l,t]=e;return{user_id:l,spend:t}});t.sort((e,l)=>l.spend-e.spend);let s=t.slice(0,5);return console.log("topKeys: ".concat(Object.values(s[0]))),s}(e)),c(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,r,n,E,F]),(0,s.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,s.jsx)(eg,{userID:n,userRole:r,accessToken:l,userSpend:null}),(0,s.jsxs)(ev.Z,{children:[(0,s.jsxs)(eS.Z,{className:"mt-2",children:[(0,s.jsx)(e_.Z,{children:"All Up"}),(0,s.jsx)(e_.Z,{children:"Team Based Usage"}),(0,s.jsx)(e_.Z,{children:"Tag Based Usage"})]}),(0,s.jsxs)(eA.Z,{children:[(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsx)(L.Z,{numColSpan:2,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Monthly Spend"}),(0,s.jsx)(ea.Z,{data:i,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top API Keys"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:d,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top Users"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:x,index:"user_id",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,s.jsx)(L.Z,{numColSpan:1,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Top Models"}),(0,s.jsx)(ea.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})})]})}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,s.jsxs)(L.Z,{numColSpan:2,children:[(0,s.jsxs)(er.Z,{className:"mb-2",children:[(0,s.jsx)(q.Z,{children:"Total Spend Per Team"}),(0,s.jsx)(eH.Z,{data:N})]}),(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Daily Spend Per Team"}),(0,s.jsx)(ea.Z,{className:"h-72",data:j,showLegend:!0,index:"date",categories:f,yAxisWidth:80,stack:!0})]})]}),(0,s.jsx)(L.Z,{numColSpan:2})]})}),(0,s.jsx)(eN.Z,{children:(0,s.jsxs)(z.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,s.jsx)(L.Z,{numColSpan:2,children:(0,s.jsxs)(er.Z,{children:[(0,s.jsx)(q.Z,{children:"Spend Per Tag - Last 30 Days"}),(0,s.jsxs)(K.Z,{children:["Get Started Tracking cost per tag ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,s.jsxs)(ec.Z,{children:[(0,s.jsx)(eh.Z,{children:(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(eu.Z,{children:"Tag"}),(0,s.jsx)(eu.Z,{children:"Spend"}),(0,s.jsx)(eu.Z,{children:"Requests"})]})}),(0,s.jsx)(ed.Z,{children:y.map(e=>(0,s.jsxs)(ex.Z,{children:[(0,s.jsx)(em.Z,{children:e.name}),(0,s.jsx)(em.Z,{children:e.value}),(0,s.jsx)(em.Z,{children:e.log_count})]},e.name))})]})]})}),(0,s.jsx)(L.Z,{numColSpan:2})]})})]})]})]})},eQ=()=>{let{Title:e,Paragraph:l}=eb.default,[t,n]=(0,a.useState)(""),[o,i]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0),j=(0,r.useSearchParams)(),g=j.get("userID"),y=j.get("token"),[Z,f]=(0,a.useState)("api-keys"),[w,b]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(y){let e=(0,ew.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),b(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),n(l),"Admin Viewer"==l&&f("usage")}else console.log("User role not defined");e.user_email?i(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?p("username_password"==e.login_method):console.log("User Email is not set ".concat(e))}}},[y]),(0,s.jsx)(a.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading..."}),children:(0,s.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,s.jsx)(c,{userID:g,userRole:t,userEmail:o,showSSOBanner:x}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,s.jsx)("div",{className:"mt-8",children:(0,s.jsx)(e$,{setPage:f,userRole:t,defaultSelectedKey:null})}),"api-keys"==Z?(0,s.jsx)(ek,{userID:g,userRole:t,teams:d,keys:h,setUserRole:n,userEmail:o,setUserEmail:i,setTeams:m,setKeys:u}):"models"==Z?(0,s.jsx)(eM,{userID:g,userRole:t,token:y,accessToken:w}):"llm-playground"==Z?(0,s.jsx)(eG,{userID:g,userRole:t,token:y,accessToken:w}):"users"==Z?(0,s.jsx)(eD,{userID:g,userRole:t,token:y,keys:h,accessToken:w,setKeys:u}):"teams"==Z?(0,s.jsx)(eL,{teams:d,setTeams:m,searchParams:j,accessToken:w,userID:g,userRole:t}):"admin-panel"==Z?(0,s.jsx)(ez,{setTeams:m,searchParams:j,accessToken:w,showSSOBanner:x}):"settings"==Z?(0,s.jsx)(eB,{userID:g,userRole:t,accessToken:w}):(0,s.jsx)(eX,{userID:g,userRole:t,token:y,accessToken:w})]})]})})}}},function(e){e.O(0,[253,971,69,744],function(){return e(e.s=79615)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/EILSdraLTRcKqOwik9Uik/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/vObviWxigsRMBvWO1QNXU/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/EILSdraLTRcKqOwik9Uik/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/vObviWxigsRMBvWO1QNXU/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/EILSdraLTRcKqOwik9Uik/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/vObviWxigsRMBvWO1QNXU/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/EILSdraLTRcKqOwik9Uik/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/vObviWxigsRMBvWO1QNXU/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index f2152a45b..a1d659986 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index d42a9ffbc..5074d20b9 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[75662,["253","static/chunks/253-ee956f196c5be23c.js","931","static/chunks/app/page-6e76bea15b095033.js"],""] +3:I[75662,["253","static/chunks/253-ee956f196c5be23c.js","931","static/chunks/app/page-b1c753f5772a7c45.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["EILSdraLTRcKqOwik9Uik",[[["",{"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/a282d1bfd6ed4df8.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["vObviWxigsRMBvWO1QNXU",[[["",{"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/a282d1bfd6ed4df8.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index c5800937b..ca23077e9 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

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

404

This page could not be found.

\ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index f2152a45b..a1d659986 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index d42a9ffbc..5074d20b9 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[75662,["253","static/chunks/253-ee956f196c5be23c.js","931","static/chunks/app/page-6e76bea15b095033.js"],""] +3:I[75662,["253","static/chunks/253-ee956f196c5be23c.js","931","static/chunks/app/page-b1c753f5772a7c45.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["EILSdraLTRcKqOwik9Uik",[[["",{"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/a282d1bfd6ed4df8.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["vObviWxigsRMBvWO1QNXU",[[["",{"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/a282d1bfd6ed4df8.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/src/components/usage.tsx b/ui/litellm-dashboard/src/components/usage.tsx index f7d53c8f3..8900a2599 100644 --- a/ui/litellm-dashboard/src/components/usage.tsx +++ b/ui/litellm-dashboard/src/components/usage.tsx @@ -274,6 +274,7 @@ const UsagePage: React.FC = ({ userID={userID} userRole={userRole} accessToken={accessToken} + userSpend={null} /> diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index 72f86f749..bbe5ae980 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -52,6 +52,7 @@ const UserDashboard: React.FC = ({ const token = searchParams.get("token"); const [accessToken, setAccessToken] = useState(null); + const [teamSpend, setTeamSpend] = useState(null); const [userModels, setUserModels] = useState([]); const [selectedTeam, setSelectedTeam] = useState( teams ? teams[0] : null @@ -174,8 +175,24 @@ const UserDashboard: React.FC = ({ fetchData(); } } + }, [userID, token, accessToken, keys, userRole]); + useEffect(() => { + // This code will run every time selectedTeam changes + if (keys !== null && selectedTeam !== null) { + let sum = 0; + for (const key of keys) { + console.log(`key in team keys: ${key.team_id}`) + console.log(`selected team: ${selectedTeam.team_id}`) + if (key.team_id !== null && key.team_id === selectedTeam.team_id) { + sum += key.spend; + } + } + setTeamSpend(sum); + } + }, [selectedTeam]); + if (userID == null || token == null) { // Now you can construct the full URL const url = proxyBaseUrl @@ -204,7 +221,7 @@ const UserDashboard: React.FC = ({ } console.log("inside user dashboard, selected team", selectedTeam); - + console.log(`teamSpend: ${teamSpend}`) return (
@@ -213,6 +230,7 @@ const UserDashboard: React.FC = ({ userID={userID} userRole={userRole} accessToken={accessToken} + userSpend={teamSpend} /> = ({ userID, userRole, accessToken }) => { - const [spend, setSpend] = useState(0.0); +const ViewUserSpend: React.FC = ({ userID, userRole, accessToken, userSpend }) => { + console.log(`userSpend: ${userSpend}`) + let [spend, setSpend] = useState(userSpend !== null ? userSpend : 0.0); const [maxBudget, setMaxBudget] = useState(0.0); useEffect(() => { const fetchData = async () => { if (!accessToken || !userID || !userRole) { return; } - if (userRole === "Admin") { + if (userRole === "Admin" && userSpend == null) { try { const globalSpend = await getTotalSpendCall(accessToken); if (globalSpend) { @@ -64,13 +66,20 @@ const ViewUserSpend: React.FC = ({ userID, userRole, accessT fetchData(); }, [userRole, accessToken]); + useEffect(() => { + if (userSpend !== null) { + setSpend(userSpend) + } + }, [userSpend]) + const displayMaxBudget = maxBudget !== null ? `$${maxBudget} limit` : "No limit"; - const roundedSpend = spend !== undefined ? spend.toFixed(5) : null; + const roundedSpend = spend !== undefined ? spend.toFixed(4) : null; + console.log(`spend in view user spend: ${spend}`) return ( <> -

Total Spend (across all teams)

+

Total Spend

${roundedSpend}