PageSourceSearch

https://ineslaguerre-getaround-mlflow-new.hf.space/static-files/static/js/3581.1169d3be.chunk.js

js ineslaguerre-getaround-mlflow-new.hf.space collected 2026-10-03 16:58:20 UTC 82,079 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunk_mlflow_mlflow=globalThis.webpackChunk_mlflow_mlflow||[]).push([[3581],{5993(e,n,i){i.d(n,{A:()=>l,h:()=>s});var t=i(68073),a=i(8449),o=i(88843);class r{}r.mlflowServices={MODEL_REGISTRY:"Model Registry",EXPERIMENTS:"Experiments",CHAT_SESSIONS:"Chat Sessions",MODEL_SERVING:"Model Serving",RUN_TRACKING:"Run Tracking"};const s=(e,n)=>{if(!(e instanceof a.s))return;const{status:i}=e;let r;const s={status:i};e.getErrorCode()===o.tG.RESOURCE_DOES_NOT_EXIST&&(r=new t.m_(s)),e.getErrorCode()===o.tG.PERMISSION_DENIED&&(r=new t.i_(s)),e.getErrorCode()===o.tG.INTERNAL_ERROR&&(r=new t.PO(s)),e.getErrorCode()===o.tG.INVALID_PARAMETER_VALUE&&(r=new t.v7(s));const l=e.getMessageField();return r&&l&&(r.message=l),r},l=r},23634(e,n,i){i.d(n,{X:()=>d});i(51477);var t=i(88605),a=i(10587),o=i(5460),r=i(63968);function s(){return(0,r.Y)(a.ds,{"data-testid":"fallback",title:(0,r.Y)(o.A,{id:"qAdWdK",defaultMessage:"Error"}),description:(0,r.Y)(o.A,{id:"RzZVxC",defaultMessage:"An error occurred while rendering this component."}),image:(0,r.Y)(a.o,{})})}function l({children:e,customFallbackComponent:n}){function i(e,n){}return n?(0,r.Y)(t.tH,{onError:i,FallbackComponent:n,children:e}):(0,r.Y)(t.tH,{onError:i,fallback:(0,r.Y)(s,{}),children:e})}function d(e,n,i,t){return function(e){return(0,r.Y)(l,{customFallbackComponent:t,children:(0,r.Y)(n,{...e})})}}},13249(e,n,i){i.d(n,{Y:()=>S});var t=i(15032),a=i(51477),o=i(10587),r=i(5460),s=i(78292),l=i(79357),d=i(24507),c=i(38881),u=i(43637),g=i(88728),p=i(58619),m=i(76039),f=i(17263),h=i(41),y=i(70111),v=i(19135),w=i(70014),x=i(53665),b=i(71974),A=i(63968);const Y=({experimentIds:e,showTokenStats:n=!1,additionalControls:i,hideTooltipLinks:s=!1,tooltipLinkUrlBuilder:Y,tooltipLinkText:S,filters:I})=>{const{theme:M}=(0,o.u)(),[k,_]=(0,a.useState)(null),[T]=(0,l.VA)(),C=T.startTime?new Date(T.startTime).getTime():void 0,D=T.endTime?new Date(T.endTime).getTime():void 0,F=(0,x.N3)(C,D),H=null!==k&&void 0!==k?k:F,E=x.ZG[H],R=(0,a.useMemo)(()=>(0,b.yB)(C,D,E),[C,D,E]);return(0,A.FD)("div",{css:(0,t.AH)({display:"flex",flexDirection:"column",gap:M.spacing.md},""),children:[(0,A.FD)("div",{css:(0,t.AH)({display:"flex",alignItems:"center",gap:M.spacing.sm,flexWrap:"wrap"},""),children:[i,(0,A.Y)(w.l,{value:H,onChange:_,startTimeMs:C,endTimeMs:D,allowClear:null!==k&&k!==F,onClear:()=>_(null)}),(0,A.Y)(d.$,{excludeOptions:["ALL"]})]}),(0,A.Y)(v.F7,{experimentIds:e,startTimeMs:C,endTimeMs:D,timeIntervalSeconds:E,timeBuckets:R,hideTooltipLinks:s,tooltipLinkUrlBuilder:Y,tooltipLinkText:S,filters:I,children:(0,A.FD)("div",{css:(0,t.AH)({display:"flex",flexDirection:"column",gap:M.spacing.md},""),children:[(0,A.Y)(c.a,{title:(0,A.Y)(r.A,{id:"6ejdmD",defaultMessage:"Requests"})}),(0,A.FD)(y.vK,{children:[(0,A.Y)(u.K,{}),(0,A.Y)(g.L,{})]}),n?(0,A.FD)(y.vK,{children:[(0,A.Y)(p.o,{}),(0,A.Y)(m.A,{title:(0,A.Y)(r.A,{id:"WHwU2F",defaultMessage:"Tokens per Request"}),subtitle:(0,A.Y)(r.A,{id:"A+GxQM",defaultMessage:"avg per request"})})]}):(0,A.Y)(p.o,{}),(0,A.FD)(y.vK,{children:[(0,A.Y)(f.q,{}),(0,A.Y)(h.m,{})]})]})})]})},S=e=>(0,A.Y)(s.k,{children:(0,A.Y)(Y,{...e})})},55082(e,n,i){i.d(n,{N:()=>t});const t={secretsConfig:["gateway_secrets_config"],endpoints:["gateway_endpoints"],bindings:["gateway_bindings"],secrets:["gateway_secrets"],modelDefinitions:["gateway_model_definitions"],providers:["gateway_providers"],budgetPolicies:["gateway_budget_policies"],budgetWindows:["gateway_budget_windows"],guardrails:["gateway_guardrails"]}},53581(e,n,i){i.r(n),i.d(n,{default:()=>Cn});var t=i(39521),a=i(23634),o=i(5993),r=i(34550),s=i(20193),l=i(51477),d=i(56511),c=i(21602),u=i(2077);var g=i(26666);var p=i(47246);var m=i(21877),f=i(70688),h=i(59559);function y(e){const n=(0,t.Zp)(),i=(0,s.jE)(),{data:a,isLoading:o,error:f}=(e=>(0,c.I)(["gateway_endpoint",e],{queryFn:()=>u.t.getEndpoint(e),retry:!1,enabled:Boolean(e)}))(e),y=null===a||void 0===a?void 0:a.endpoint,v=(0,r.mN)({defaultValues:{name:"",trafficSplitModels:[],fallbackModels:[],usageTracking:!1,experimentId:""}});(0,l.useEffect)(()=>{if(y&&y.model_mappings){var e,n,i,t,a;const o=null!==(e=y.model_mappings.filter(e=>"PRIMARY"===e.linkage_type))&&void 0!==e?e:[],r=null!==(n=y.model_mappings.filter(e=>"FALLBACK"===e.linkage_type))&&void 0!==n?n:[],s=o.reduce((e,n)=>{var i;return e+(null!==(i=n.weight)&&void 0!==i?i:1)},0);v.reset({name:null!==(i=y.name)&&void 0!==i?i:"",trafficSplitModels:o.map(e=>{var n,i,t,a,r,l,d,c,u,g;return{modelDefinitionId:null===(n=e.model_definition)||void 0===n?void 0:n.model_definition_id,modelDefinitionName:null!==(i=null===(t=e.model_definition)||void 0===t?void 0:t.name)&&void 0!==i?i:"",provider:null!==(a=null===(r=e.model_definition)||void 0===r?void 0:r.provider)&&void 0!==a?a:"",modelName:null!==(l=null===(d=e.model_definition)||void 0===d?void 0:d.model_name)&&void 0!==l?l:"",secretMode:"existing",existingSecretId:null!==(c=null===(u=e.model_definition)||void 0===u?void 0:u.secret_id)&&void 0!==c?c:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}},weight:s>0?(null!==(g=e.weight)&&void 0!==g?g:1)/s*100:100/o.length}}),fallbackModels:r.sort((e,n)=>{var i,t;return(null!==(i=e.fallback_order)&&void 0!==i?i:0)-(null!==(t=n.fallback_order)&&void 0!==t?t:0)}).map((e,n)=>{var i,t,a,o,r,s,l,d,c;return{modelDefinitionId:null===(i=e.model_definition)||void 0===i?void 0:i.model_definition_id,modelDefinitionName:null!==(t=null===(a=e.model_definition)||void 0===a?void 0:a.name)&&void 0!==t?t:"",provider:null!==(o=null===(r=e.model_definition)||void 0===r?void 0:r.provider)&&void 0!==o?o:"",modelName:null!==(s=null===(l=e.model_definition)||void 0===l?void 0:l.model_name)&&void 0!==s?s:"",secretMode:"existing",existingSecretId:null!==(d=null===(c=e.model_definition)||void 0===c?void 0:c.secret_id)&&void 0!==d?d:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}},fallbackOrder:n+1}}),usageTracking:null!==(t=y.usage_tracking)&&void 0!==t&&t,experimentId:null!==(a=y.experiment_id)&&void 0!==a?a:""},{keepDirtyValues:!0})}},[y,v]);const{mutateAsync:w,error:x,isLoading:b}=(()=>{const e=(0,s.jE)();return(0,g.n)({mutationFn:e=>u.t.updateEndpoint({endpoint_id:e.endpointId,name:e.name,model_configs:e.model_configs,routing_strategy:e.routing_strategy,fallback_config:e.fallback_config,usage_tracking:e.usage_tracking,experiment_id:e.experiment_id}),onSuccess:()=>
1{e.invalidateQueries(["gateway_endpoints"]),e.invalidateQueries(["gateway_endpoint"])}})})(),{mutateAsync:A}=(0,m.w)(),{mutateAsync:Y}=(0,p.H)(),{mutateAsync:S}=(()=>{const e=(0,s.jE)();return(0,g.n)({mutationFn:e=>u.t.updateModelDefinition({model_definition_id:e.modelDefinitionId,secret_id:e.secretId,provider:e.provider,model_name:e.modelName}),onSuccess:()=>{e.invalidateQueries(["gateway_endpoints"]),e.invalidateQueries(["gateway_endpoint"]),e.invalidateQueries(["gateway_model_definitions"])}})})(),I=b,M=x,k=(0,l.useCallback)(async e=>{if(y)try{const i=async e=>{if("existing"===e.secretMode)return e.existingSecretId;return(await A({secret_name:e.newSecret.name,secret_value:e.newSecret.secretFields,provider:e.provider,auth_config:e.newSecret.configFields})).secret.secret_id},t=async n=>{if(n.modelDefinitionId){var t;const e=null===(t=y.model_mappings)||void 0===t?void 0:t.find(e=>{var i;return(null===(i=e.model_definition)||void 0===i?void 0:i.model_definition_id)===n.modelDefinitionId});if(null!==e&&void 0!==e&&e.model_definition){if(n.provider!==e.model_definition.provider||n.modelName!==e.model_definition.model_name||"existing"===n.secretMode&&n.existingSecretId!==e.model_definition.secret_id||"new"===n.secretMode){const e=await i(n);await S({modelDefinitionId:n.modelDefinitionId,secretId:e,provider:n.provider,modelName:n.modelName})}}return n.modelDefinitionId}const a=await i(n);if(!n.provider||!n.modelName)throw new Error("Provider and model name are required to create a model definition");const o=Date.now();let r=`${e.name||y.name}-${n.provider}-${n.modelName}-${o}`.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");r||(r=`model-definition-${o}`);return(await Y({name:r,secret_id:a,provider:n.provider,model_name:n.modelName})).model_definition.model_definition_id},a=await Promise.all(e.trafficSplitModels.map(e=>t(e))),o=await Promise.all(e.fallbackModels.map(e=>t(e))),r=e.trafficSplitModels.reduce((e,n)=>e+n.weight,0),s=e.trafficSplitModels.length||1,l=[...e.trafficSplitModels.map((e,n)=>({model_definition_id:a[n],linkage_type:"PRIMARY",weight:r>0?e.weight/100:1/s})),...e.fallbackModels.map((e,n)=>({model_definition_id:o[n],linkage_type:"FALLBACK",fallback_order:e.fallbackOrder}))],d=e.trafficSplitModels.length>1?"REQUEST_BASED_TRAFFIC_SPLIT":void 0,c=e.fallbackModels.length>0?{strategy:"SEQUENTIAL",max_attempts:e.fallbackModels.length+1}:void 0;await w({endpointId:y.endpoint_id,name:e.name||void 0,model_configs:l,routing_strategy:d,fallback_config:c,usage_tracking:e.usageTracking}),n(h.Ay.getEndpointDetailsRoute(y.endpoint_id))}catch{}},[y,w,n,A,Y,S]),_=(0,l.useCallback)(()=>{v.reset()},[v]),T=(0,l.useCallback)(async n=>{y&&(await w({endpointId:y.endpoint_id,name:n}),i.invalidateQueries({queryKey:["gateway","endpoint",e]}),i.invalidateQueries({queryKey:["gateway","endpoints"]}))},[y,w,i,e]),C=(0,l.useCallback)(async e=>{if(!y)return;const n=v.getValues("usageTracking");if(n!==e){v.setValue("usageTracking",e);try{await w({endpointId:y.endpoint_id,usage_tracking:e})}catch{v.setValue("usageTracking",n)}}},[y,v,w]),D=v.watch("trafficSplitModels"),F=v.watch("fallbackModels"),H=(0,l.useMemo)(()=>{if(0===D.length)return!1;const e=D.reduce((e,n)=>e+n.weight,0);if(Math.abs(e-100)>.01)return!1;const n=e=>{if(!e.provider||!e.modelName)return!1;if("existing"===e.secretMode)return Boolean(e.existingSecretId);{if(!e.newSecret)return!1;const n=Boolean(e.newSecret.name&&e.newSecret.authMode),i=!!e.newSecret.secretFields&&Object.values(e.newSecret.secretFields).some(e=>e);return n&&i}},i=D.every(n),t=F.every(n);return i&&t},[D,F]),E=v.watch("name"),R=(0,l.useMemo)(()=>{var e,n,i,t,a;if(!y)return!1;const o=null!==(e=y.name)&&void 0!==e?e:"";if(E!==o)return!0;const r=null!==(n=null===(i=y.model_mappings)||void 0===i?void 0:i.filter(e=>"PRIMARY"===e.linkage_type))&&void 0!==n?n:[],s=null!==(t=null===(a=y.model_mappings)||void 0===a?void 0:a.filter(e=>"FALLBACK"===e.linkage_type))&&void 0!==t?t:[];if(D.length!==r.length)return!0;if(F.length!==s.length)return!0;const l=r.reduce((e,n)=>{var i;return e+(null!==(i=n.weight)&&void 0!==i?i:1)},0),d=D.some((e,n)=>{var i;const t=r[n];if(!t||!t.model_definition)return!0;const a=l>0?(null!==(i=t.weight)&&void 0!==i?i:1)/l*100:100/r.length;if(e.modelDefinitionId&&e.modelDefinitionId!==t.model_definition.model_definition_id)return!0;
1if(e.modelDefinitionId&&e.modelDefinitionId===t.model_definition.model_definition_id){if(e.provider!==t.model_definition.provider||e.modelName!==t.model_definition.model_name||"existing"===e.secretMode&&e.existingSecretId!==t.model_definition.secret_id||"new"===e.secretMode)return!0}return e.provider!==t.model_definition.provider||e.modelName!==t.model_definition.model_name||"existing"!==e.secretMode||e.existingSecretId!==t.model_definition.secret_id||Math.abs(e.weight-a)>.01}),c=F.some(e=>{if(!e.modelDefinitionId)return!0;const n=s.find(n=>{var i;return(null===(i=n.model_definition)||void 0===i?void 0:i.model_definition_id)===e.modelDefinitionId});if(!n)return!0;if(n.model_definition){if(e.provider!==n.model_definition.provider||e.modelName!==n.model_definition.model_name||"existing"===e.secretMode&&e.existingSecretId!==n.model_definition.secret_id||"new"===e.secretMode)return!0}return n.fallback_order!==e.fallbackOrder});return d||c},[y,E,D,F]),{data:N}=(0,d.c)();return{form:v,isLoadingEndpoint:o,isSubmitting:I,loadError:f,mutationError:M,endpoint:y,existingEndpoints:N,isFormComplete:H,hasChanges:R,handleSubmit:k,handleCancel:_,handleNameUpdate:T,handleUsageTrackingUpdate:C}}var v=i(15032),w=i(10587),x=i(77753),b=i(5460),A=i(74343),Y=i(19740),S=i(76887),I=i(63695),M=i(18555),k=i(2624),_=i(54334),T=i(74102),C=i(66672),D=i(69332),F=i(74273),H=i(63968);var E={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},R={name:"1hhxok4",styles:"margin:0;font-weight:bold"},N={name:"1u1zie3",styles:"width:120px"},L={name:"1d3w5wq",styles:"width:100%"};const B=({model:e,index:n,onModelChange:i,onWeightChange:t,onRemove:a,componentId:o})=>{const{theme:r}=(0,w.u)(),s=(0,A.A)(),d=(0,l.useRef)(`traffic-split-${Math.random().toString(36).slice(2,9)}`).current,[c,u]=(0,l.useState)(!e.provider&&!e.modelName),[g,p]=(0,l.useState)(null),m=null!==g&&void 0!==g?g:0===e.weight?"":String(e.weight),{existingSecrets:f,isLoadingSecrets:h,authModes:y,defaultAuthMode:Y,isLoadingProviderConfig:S}=(0,D.t)({provider:e.provider}),I={mode:e.secretMode,existingSecretId:e.existingSecretId,newSecret:e.newSecret},M=e.provider&&e.modelName;return(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:r.spacing.md,padding:r.spacing.md,border:`2px solid ${r.colors.border}`,borderRadius:r.borders.borderRadiusMd,backgroundColor:r.colors.backgroundPrimary},""),children:[(0,H.FD)("div",{css:E,children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:r.spacing.sm,flex:1},""),children:[(0,H.Y)(w.B,{componentId:`${o}.expand`,icon:c?(0,H.Y)(w.E,{}):(0,H.Y)(w.j,{}),onClick:()=>u(!c),size:"small"}),(0,H.Y)(x.FormUI.Label,{css:R,children:(0,H.Y)(b.A,{id:"JNmxAa",defaultMessage:"Model {number}",values:{number:n+1}})}),!c&&M&&(0,H.FD)(w.T.Text,{css:(0,v.AH)({fontFamily:"monospace",color:r.colors.textSecondary},""),children:[(0,F.aU)(e.provider)," / ",e.modelName,(0,H.FD)("span",{css:(0,v.AH)({marginLeft:r.spacing.sm,color:r.colors.actionTertiaryTextDefault},""),children:["(",e.weight,"%)"]})]})]}),(0,H.Y)(w.s,{componentId:`${o}.remove-tooltip`,content:s.formatMessage({id:"eWm+AG",defaultMessage:"Remove model"}),children:(0,H.Y)(w.B,{componentId:`${o}.remove`,icon:(0,H.Y)(w.hF,{}),onClick:()=>a(n)})})]}),c&&(0,H.FD)(H.FK,{children:[(0,H.Y)(_.U,{value:e.provider,onChange:e=>{i(n,{provider:e,modelName:"",secretMode:"new",existingSecretId:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}}})},componentId:`${o}.provider`}),(0,H.Y)(T.o,{provider:e.provider,value:e.modelName,onChange:e=>i(n,{modelName:e}),componentId:`${o}.model`}),(0,H.Y)(C.$,{value:I,onChange:e=>{i(n,{secretMode:e.mode,existingSecretId:e.existingSecretId,newSecret:e.newSecret})},provider:e.provider,existingSecrets:f,isLoadingSecrets:h,authModes:y,defaultAuthMode:Y,isLoadingProviderConfig:S,componentId:`${o}.api-key`}),(0,H.FD)("div",{css:N,children:[(0,H.Y)(x.FormUI.Label,{htmlFor:`${d}.weight`,children:(0,H.Y)(b.A,{id:"pOqgMC",defaultMessage:"Weight"})}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:r.spacing.xs},""),children:[(0,H.Y)(k.f,{id:`${d}.weight`,componentId:`${o}.weight`,type:"number",min:0,max:100,value:m,onChange:e=>{p(e.target.value);const i=parseInt(e.target.value,10);t(n,Number.isNaN(i)?0:i)},css:L}),(0,H.Y)("span",{css:(0,v.AH)({color:r.colors.textSecondary},""),children:"%"})]})]})]})]})};var z={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},O={name:"xyzkeb",styles:"align-self:flex-start"};
1const P=({value:e,onChange:n,componentId:i="mlflow.gateway.traffic-split"})=>{const{theme:t}=(0,w.u)(),a=(0,l.useCallback)(()=>{n([...e,{modelDefinitionName:"",provider:"",modelName:"",secretMode:"new",existingSecretId:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}},weight:0}])},[e,n]),o=(0,l.useCallback)(i=>{n(e.filter((e,n)=>n!==i))},[e,n]),r=(0,l.useCallback)((i,t)=>{const a=[...e];a[i]={...a[i],...t},n(a)},[e,n]),s=(0,l.useCallback)((i,t)=>{const a=[...e];a[i]={...a[i],weight:t},n(a)},[e,n]),d=e.reduce((e,n)=>e+n.weight,0),c=100===d;return(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:t.spacing.md},""),children:[e.map((e,n)=>(0,H.Y)(B,{model:e,index:n,onModelChange:r,onWeightChange:s,onRemove:o,componentId:i},n)),(0,H.FD)("div",{css:z,children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:t.spacing.xs},""),children:[(0,H.Y)(w.B,{componentId:`${i}.add`,onClick:a,css:O,children:(0,H.Y)(b.A,{id:"0RVMB3",defaultMessage:"Add model"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:t.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"n7MxV7",defaultMessage:"Use multiple models for load balancing by splitting traffic with weights"})})]}),e.length>0&&(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:t.spacing.xs,color:c?t.colors.textSecondary:t.colors.textValidationDanger,fontSize:t.typography.fontSizeSm},""),children:[(0,H.Y)(b.A,{id:"6fV0+T",defaultMessage:"Total: {total}%",values:{total:d}}),!c&&(0,H.Y)(b.A,{id:"ftZaLl",defaultMessage:"(must equal 100%)"})]})]})]})};var $=i(43668),j=i(73465);const q=()=>{const{theme:e}=(0,w.u)();return(0,H.Y)("div",{css:(0,v.AH)({width:2,height:e.spacing.md,backgroundColor:e.colors.border},"")})};var U={name:"zigog8",styles:"display:flex;flex-direction:column;align-items:center"};const G=()=>{const{theme:e}=(0,w.u)();return(0,H.FD)("div",{css:U,children:[(0,H.Y)(q,{}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({padding:`${e.spacing.xs}px ${e.spacing.sm}px`,fontSize:e.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"+n4BXZ",defaultMessage:"Fallback"})}),(0,H.Y)(q,{})]})};var V=i(89025),W=i(68551);const K="FALLBACK_MODEL";var J={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},Q={name:"1hhxok4",styles:"margin:0;font-weight:bold"};const X=({model:e,index:n,onModelChange:i,onRemove:t,onMove:a,componentId:o})=>{const{theme:r}=(0,w.u)(),s=(0,A.A)(),[d,c]=(0,l.useState)(!e.provider&&!e.modelName),u=(0,l.useRef)(null),[{isDragging:g},p,m]=(0,V.i)({type:K,item:{type:K,index:n},collect:e=>({isDragging:e.isDragging()})}),[{isOver:f},h]=(0,W.H)({accept:K,hover:e=>{if(!u.current)return;const i=e.index,t=n;i!==t&&(a(i,t),e.index=t)},collect:e=>({isOver:e.isOver()})});m(h(u));const{existingSecrets:y,isLoadingSecrets:Y,authModes:S,defaultAuthMode:I,isLoadingProviderConfig:M}=(0,D.t)({provider:e.provider}),k={mode:e.secretMode,existingSecretId:e.existingSecretId,newSecret:e.newSecret},E=e.provider&&e.modelName;return(0,H.FD)("div",{ref:u,css:(0,v.AH)({display:"flex",flexDirection:"column",gap:r.spacing.md,padding:r.spacing.md,border:`2px solid ${r.colors.border}`,borderRadius:r.borders.borderRadiusMd,backgroundColor:r.colors.backgroundPrimary,opacity:g?.5:1,borderColor:f?r.colors.actionPrimaryBackgroundDefault:r.colors.border},""),children:[(0,H.FD)("div",{css:J,children:[(0,H.FD)("div",{ref:p,css:(0,v.AH)({display:"flex",alignItems:"center",gap:r.spacing.sm,flex:1,cursor:"grab","&:active":{cursor:"grabbing"}},""),children:[(0,H.Y)(x.FormUI.Label,{css:Q,children:(0,H.Y)(b.A,{id:"hDExYR",defaultMessage:"Fallback Model {order}",values:{order:n+1}})}),(0,H.Y)(w.B,{componentId:`${o}.expand`,icon:d?(0,H.Y)(w.E,{}):(0,H.Y)(w.j,{}),onClick:()=>c(!d),size:"small"}),!d&&E&&(0,H.FD)(w.T.Text,{css:(0,v.AH)({fontFamily:"monospace",color:r.colors.textSecondary},""),children:[(0,F.aU)(e.provider)," / ",e.modelName]})]}),(0,H.Y)(w.s,{componentId:`${o}.remove-tooltip`,content:s.formatMessage({id:"XZlIAj",defaultMessage:"Remove fallback model"}),children:(0,H.Y)(w.B,{componentId:`${o}.remove`,icon:(0,H.Y)(w.hF,{}),onClick:()=>t(n)})})]}),d&&(0,H.FD)(H.FK,{children:[(0,H.Y)(_.U,{value:e.provider,onCh
1ange:e=>{i(n,{provider:e,modelName:"",secretMode:"new",existingSecretId:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}}})},componentId:`${o}.provider`}),(0,H.Y)(T.o,{provider:e.provider,value:e.modelName,onChange:e=>i(n,{modelName:e}),componentId:`${o}.model`}),(0,H.Y)(C.$,{value:k,onChange:e=>{i(n,{secretMode:e.mode,existingSecretId:e.existingSecretId,newSecret:e.newSecret})},provider:e.provider,existingSecrets:y,isLoadingSecrets:Y,authModes:S,defaultAuthMode:I,isLoadingProviderConfig:M,componentId:`${o}.api-key`})]})]})};var Z={name:"1fttcpj",styles:"display:flex;flex-direction:column"},ee={name:"zl1inp",styles:"display:flex;justify-content:center"},ne={name:"zl1inp",styles:"display:flex;justify-content:center"},ie={name:"qbt5ty",styles:"align-self:center"};const te=({value:e,onChange:n,componentId:i="mlflow.gateway.fallback"})=>{const t=(0,l.useCallback)(()=>{const i=e.length>0?Math.max(...e.map(e=>e.fallbackOrder))+1:1;n([...e,{modelDefinitionName:"",provider:"",modelName:"",secretMode:"new",existingSecretId:"",newSecret:{name:"",authMode:"",secretFields:{},configFields:{}},fallbackOrder:i}])},[e,n]),a=(0,l.useCallback)(i=>{const t=e.filter((e,n)=>n!==i).map((e,n)=>({...e,fallbackOrder:n+1}));n(t)},[e,n]),o=(0,l.useCallback)((i,t)=>{const a=[...e];a[i]={...a[i],...t},n(a)},[e,n]),r=(0,l.useCallback)((i,t)=>{const a=[...e],[o]=a.splice(i,1);a.splice(t,0,o);const r=a.map((e,n)=>({...e,fallbackOrder:n+1}));n(r)},[e,n]);return(0,H.Y)($.Q,{backend:j.t2,children:(0,H.FD)("div",{css:Z,children:[e.length>0?(0,H.Y)(G,{}):(0,H.Y)("div",{css:ee,children:(0,H.Y)(q,{})}),e.map((e,n)=>(0,H.FD)("div",{children:[n>0&&(0,H.Y)(G,{}),(0,H.Y)(X,{model:e,index:n,onModelChange:o,onRemove:a,onMove:r,componentId:i})]},n)),e.length>0&&(0,H.Y)("div",{css:ne,children:(0,H.Y)(q,{})}),(0,H.Y)(w.B,{componentId:`${i}.add`,onClick:t,css:ie,children:(0,H.Y)(b.A,{id:"NlwpVQ",defaultMessage:"Add fallback"})})]})})};var ae=i(51605),oe=i(49149),re=i(52821),se=i(29148);function le(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function de(e,n){const i=new Error(e);return i.responseBody=n,i}var ce={name:"l2hjmg",styles:"display:flex;flex-direction:column;flex:1;min-height:0"},ue={name:"6ey9w8",styles:"flex:1;min-width:0;display:flex;flex-direction:column"},ge={name:"6ey9w8",styles:"flex:1;min-width:0;display:flex;flex-direction:column"};const pe=({description:e,requestTooltipContent:n,componentId:i,tryItRequestUrl:t,tryItDefaultBody:a,tryItOptions:o})=>{var r,s;const{theme:d}=(0,w.u)(),[c,u]=(0,l.useState)(a),{data:p,isLoading:m,error:f,sendRequest:h,reset:y}=function({tryItRequestUrl:e,options:n}){var i;const t=(0,g.n)({mutationFn:async i=>{let t;try{t=JSON.parse(i)}catch{throw de("Invalid JSON in request body")}try{const i=null===n||void 0===n||!n.headers||"object"!==typeof n.headers||n.headers instanceof Headers?{}:n.headers,a=await(0,re.qP)(e,{...n,method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)});return le(await a.text())}catch(r){var a;let e=r instanceof Error?r.message:String(r);const n=r instanceof se.Un,i=n?await(null===(a=r.response)||void 0===a?void 0:a.text())||"":void 0,t=void 0!==i?le(i):void 0;if(i&&n&&r.status)try{if("string"===typeof JSON.parse(i).detail){var o;const n=(null===(o=r.response)||void 0===o?void 0:o.statusText)||`Error ${r.status}`;e=`${r.status} ${n}`}}catch{}throw de(e,t)}}});return{data:t.data,isLoading:t.isLoading,error:null!==(i=t.error)&&void 0!==i?i:void 0,sendRequest:t.mutate,reset:t.reset}}({tryItRequestUrl:t,options:o}),A=f?null!==(r=f.responseBody)&&void 0!==r?r:"":null!==p&&void 0!==p?p:"",Y=null!==(s=null===f||void 0===f?void 0:f.message)&&void 0!==s?s:null,S=(0,l.useCallback)(()=>{h(c)},[h,c]),I=(0,l.useCallback)(()=>{y(),u(a)},[y,a]);return(0,l.useEffect)(()=>{I()},[I]),(0,H.FD)("div",{css:ce,children:[(0,H.FD)("div",{css:(0,v.AH)({flex:1,overflowY:"auto",minHeight:0,display:"flex",flexDirection:"column",gap:d.spacing.md},""),children:[(0,H.Y)(w.T.Text,{color:"secondary",children:e}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",gap:d.spacing.md},""),children:[(0,H.FD)("div",{css:ue,children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:d.spacing.xs,marginBottom:
1d.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,children:(0,H.Y)(b.A,{id:"rJWzb6",defaultMessage:"Request"})}),(0,H.Y)(w.eA,{componentId:i,content:n})]}),(0,H.Y)(x.Input.TextArea,{componentId:"mlflow.gateway.usage-modal.try-it.request",value:c,onChange:e=>u(e.target.value),disabled:m,rows:14,css:(0,v.AH)({fontFamily:"monospace",fontSize:d.typography.fontSizeSm,minHeight:220},"")})]}),(0,H.FD)("div",{css:ge,children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:d.spacing.xs,marginBottom:d.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,children:(0,H.Y)(b.A,{id:"2N2M5a",defaultMessage:"Response"})}),(0,H.Y)(w.eA,{componentId:"mlflow.gateway.usage-modal.try-it.response-tooltip",content:(0,H.Y)(b.A,{id:"AbCFL2",defaultMessage:"Response from the endpoint after clicking Send request."})})]}),(0,H.Y)("div",{"aria-live":"polite","aria-atomic":"true",role:"status",children:(0,H.Y)(x.Input.TextArea,{componentId:"mlflow.gateway.usage-modal.try-it.response",value:A,readOnly:!0,rows:14,placeholder:Y||m?void 0:'Click "Send request" to see the response here.',css:(0,v.AH)({fontFamily:"monospace",fontSize:d.typography.fontSizeSm,backgroundColor:d.colors.backgroundSecondary,minHeight:220},"")})}),(0,H.Y)("div",{css:(0,v.AH)({minHeight:"1.5em",marginTop:d.spacing.xs},""),"aria-live":"polite","aria-atomic":"true",role:"status",children:Y&&(0,H.Y)(w.T.Text,{color:"error",children:Y})})]})]})]}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",gap:d.spacing.sm,flexShrink:0,backgroundColor:d.colors.backgroundPrimary,paddingTop:d.spacing.sm,paddingBottom:d.spacing.sm,borderTop:`1px solid ${d.colors.border}`},""),children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.usage-modal.try-it.send",type:"primary",onClick:S,disabled:m,loading:m,children:m?(0,H.Y)(b.A,{id:"3cn8ue",defaultMessage:"Sending..."}):(0,H.Y)(b.A,{id:"h48hnl",defaultMessage:"Send request"})}),(0,H.Y)(w.B,{componentId:"mlflow.gateway.usage-modal.try-it.reset",onClick:I,disabled:m,children:(0,H.Y)(b.A,{id:"eIdMWq",defaultMessage:"Reset example"})})]})]})};var me=i(98761);const fe="# Unified OpenAI compatible API for model invocations. Set the endpoint name as the model parameter.",he=()=>"undefined"!==typeof window?window.location.origin:"http://localhost:5000",ye=({endpointName:e,codingAgent:n})=>{const{theme:i}=(0,w.u)(),t=(0,l.useMemo)(()=>he(),[]),{bash:a,description:o}=(0,l.useMemo)(()=>((e,n,i)=>{switch(i){case"claude-code":return{description:"Set the environment variable below, then run `claude` as usual.",bash:`export ANTHROPIC_BASE_URL="${e}/gateway/proxy/${n}"\n\nclaude`};case"codex":return{description:"Pass the gateway URL as the base URL when running Codex.",bash:`codex --config 'openai_base_url="${e}/gateway/proxy/${n}/v1"'`};case"gemini-cli":return{description:"Set the environment variable below, then run `gemini` as usual.",bash:`export GOOGLE_GEMINI_BASE_URL="${e}/gateway/proxy/${n}"\n\ngemini`}}})(t,e,n),[t,e,n]);return(0,H.FD)("div",{css:(0,v.AH)({padding:i.spacing.md,border:`1px solid ${i.colors.border}`,borderRadius:i.borders.borderRadiusMd,backgroundColor:i.colors.backgroundSecondary},""),children:[(0,H.Y)(w.T.Title,{level:3,css:(0,v.AH)({margin:0,marginBottom:i.spacing.sm},""),children:(0,H.Y)(b.A,{id:"kwqwaU",defaultMessage:"View starter code"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:i.spacing.md},""),children:o}),(0,H.FD)("div",{css:(0,v.AH)({border:`1px solid ${i.colors.borderDecorative}`,borderRadius:i.borders.borderRadiusMd,backgroundColor:i.colors.backgroundPrimary,overflow:"hidden"},""),children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"space-between",alignItems:"center",padding:`${i.spacing.sm}px ${i.spacing.md}px`,borderBottom:`1px solid ${i.colors.borderDecorative}`},""),children:[(0,H.Y)(w.T.Text,{bold:!0,css:(0,v.AH)({fontSize:i.typography.fontSizeSm},""),children:me.Zq[n]}),(0,H.Y)(ae.i,{componentId:"mlflow.gateway.edit-endpoint.coding-agent-starter-code.copy",copyText:a,icon:(0,H.Y)(w.cV,{}),showLabel:!1})]}),(0,H.Y)(oe.z7,{language:"text",theme:i.isDarkMode?"duotoneDark":"light",style:{fontSize:i.typography.fontSizeSm,padding:`${i.spacing.sm}px ${i.spacing.md}px`,margin:0},children:a})]})]})};var ve={name:"ti75j2",styles:"margin:0"},we={name:"v92fmm",styles:"min-height:400px"};const xe=({endpointName:e,provider:n})=>{const{theme:i}=(0,w.u)(),[t,a]=(0,l.useState)("chat-completions"),[o,r]=(0,l.useState)("curl"),[s,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(0),g=(0,l.useCallback)(()=>{u(e=>e+1),d(!0)},[]),p=(0,l.useMemo)(()=>(e=>{switch(e){case"openai":case"azure":return{variant:"openai-responses",label:"OpenAI Responses"};case"anthropic":return{variant:"anthropic-messages",label:"Anthropic Messages"};case"gemini":return{variant:"gemini-generate",label:"Gemini Generate Content"};default:return null}})(n),[n]),m=(0,l.useMemo)(()=>{const e=[{value:"chat-completions",label:"MLflow Chat Completions"}];return p&&e.push({value:p.variant,label:p.label}),e},[p]),f=(0,l.useMemo)(()=>he(),[]),h=(0,l.useMemo)(()=>((e,n,i)=>{switch(i){case"chat-completions":return{curl:`${fe}\n\ncurl -X POST ${e}/gateway/mlflow/v1/chat/completions \\\n  -H "Content-Type: application/json" \\\n  -d '{\n  "model": "${n}",\n  "messages": [\n    {"role": "user", "content": "How are you?"}\n  ]\n}'`,python:`${fe}\n\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url="${e}
1/gateway/mlflow/v1",\n    api_key="",  # API key not needed, configured server-side\n)\n\nmessages = [{"role": "user", "content": "How are you?"}]\n\nresponse = client.chat.completions.create(\n    model="${n}",  # Endpoint name as model\n    messages=messages,\n)\nprint(response.choices[0].message)`};case"openai-responses":return{curl:`# Passthrough to OpenAI's Responses API, supporting multi-turn conversations\n# with vision and audio. New OpenAI features are available immediately.\n\ncurl -X POST ${e}/gateway/openai/v1/responses \\\n  -H "Content-Type: application/json" \\\n  -d '{\n  "model": "${n}",\n  "input": "How are you?"\n}'`,python:`# Passthrough to OpenAI's Responses API, supporting multi-turn conversations\n# with vision and audio. New OpenAI features are available immediately.\n\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url="${e}/gateway/openai/v1",\n    api_key="dummy",  # API key not needed, configured server-side\n)\n\nresponse = client.responses.create(\n    model="${n}",\n    input="How are you?",\n)\nprint(response.output_text)`};case"anthropic-messages":return{curl:`# Passthrough to Anthropic's Messages API with Claude-specific features.\n# New Anthropic features are available immediately.\n\ncurl -X POST ${e}/gateway/anthropic/v1/messages \\\n  -H "Content-Type: application/json" \\\n  -d '{\n  "model": "${n}",\n  "max_tokens": 1024,\n  "messages": [\n    {"role": "user", "content": "How are you?"}\n  ]\n}'`,python:`# Passthrough to Anthropic's Messages API with Claude-specific features.\n# New Anthropic features are available immediately.\n\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url="${e}/gateway/anthropic",\n    api_key="dummy",  # API key not needed, configured server-side\n)\n\nresponse = client.messages.create(\n    model="${n}",\n    max_tokens=1024,\n    messages=[{"role": "user", "content": "How are you?"}],\n)\nprint(response.content[0].text)`};case"gemini-generate":return{curl:`# Passthrough to Google's Gemini API. New Google features are available immediately.\n# Note: endpoint name is part of the URL path.\n\ncurl -X POST ${e}/gateway/gemini/v1beta/models/${n}:generateContent \\\n  -H "Content-Type: application/json" \\\n  -d '{\n  "contents": [{\n    "parts": [{"text": "How are you?"}]\n  }]\n}'`,python:`# Passthrough to Google's Gemini API. New Google features are available immediately.\n# Note: endpoint name is part of the URL path.\n\nfrom google import genai\n\n# Configure with custom endpoint\nclient = genai.Client(\n    api_key='dummy',\n    http_options={\n        'base_url': "${e}/gateway/gemini",\n    }\n)\nresponse = client.models.generate_content(\n    model="${n}",\n    contents={'text': 'How are you?'},\n)\nclient.close()\nprint(response.candidates[0].content.parts[0].text)`}}})(f,e,t),[f,e,t]),y="curl"===o?h.curl:h.python,A=(0,l.useMemo)(()=>((e,n,i)=>{switch(i){case"chat-completions":return`${e}/gateway/mlflow/v1/chat/completions`;case"openai-responses":return`${e}/gateway/openai/v1/responses`;case"anthropic-messages":return`${e}/gateway/anthropic/v1/messages`;case"gemini-generate":return`${e}/gateway/gemini/v1beta/models/${n}:generateContent`}})(f,e,t),[f,e,t]),Y=(0,l.useMemo)(()=>((e,n)=>{switch(n){case"chat-completions":return JSON.stringify({model:e,messages:[{role:"user",content:"How are you?"}]},null,2);case"openai-responses":return JSON.stringify({model:e,input:"How are you?"},null,2);case"anthropic-messages":return JSON.stringify({model:e,max_tokens:1024,messages:[{role:"user",content:"How are you?"}]},null,2);case"gemini-generate":return JSON.stringify({contents:[{parts:[{text:"How are you?"}]}]},null,2)}})(e,t),[e,t]),S="anthropic-messages"===t?{headers:{"anthropic-dangerous-direct-browser-access":"true"}}:void 0;return(0,H.FD)("div",{css:(0,v.AH)({padding:i.spacing.md,border:`1px solid ${i.colors.border}`,borderRadius:i.borders.borderRadiusMd,backgroundColor:i.colors.backgroundSecondary},""),children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:i.spacing.sm},""),children:[(0,H.Y)(w.T.Title,{level:3,css:ve,children:(0,H.Y)(b.A,{id:"gCCsKd",defaultMessage:"View starter code"})}),(0,H.Y)(x.SegmentedControlGroup,{name:"starter-code-api",componentId:"mlflow.gateway.edit-endpoint.starter-code.api",value:t,onChange:({target:{value:e}})=>a(e),children:m.map(e=>(0,H.Y)(x.SegmentedControlButton,{value:e.value,children:e.label},e.value))})]}),(0,H.FD)("div",{css:(0,v.AH)({marginTop:i.spacing.md,border:`1px solid ${i.colors.borderDecorative}`,borderRadius:i.borders.borderRadiusMd,backgroundColor:i.colors.backgroundPrimary,overflow:"hidden"},""),children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"space-between",alignItems:"flex-end",padding:`${i.spacing.sm}px ${i.spacing.md}px 0 ${i.spacing.md}px`,borderBottom:`1px solid ${i.colors.borderDecorative}`},""),children:[(0,H.Y)("div",{css:(0,v.AH)({display:"flex",gap:i.spacing.md},""),children:["curl","python"].map(e=>(0,H.Y)("button",{type:"button",onClick:()=>r(e),css:(0,v.AH)({background:"none",border:"none",borderBottom:`2px solid ${o===e?i.colors.actionPrimaryBackgroun
1dDefault:"transparent"}`,padding:`${i.spacing.sm}px 0`,cursor:"pointer",fontSize:i.typography.fontSizeBase,fontWeight:o===e?i.typography.typographyBoldFontWeight:"normal",color:o===e?i.colors.textPrimary:i.colors.textSecondary,"&:hover":{color:i.colors.textPrimary}},""),children:"curl"===e?"cURL":"Python"},e))}),(0,H.Y)(ae.i,{componentId:"mlflow.gateway.edit-endpoint.starter-code.copy",copyText:y,icon:(0,H.Y)(w.cV,{}),showLabel:!1})]}),(0,H.Y)(oe.z7,{language:"python"===o?"python":"text",theme:i.isDarkMode?"duotoneDark":"light",style:{fontSize:i.typography.fontSizeSm,padding:`${i.spacing.sm}px ${i.spacing.md}px`,margin:0},children:y})]}),(0,H.Y)("div",{css:(0,v.AH)({display:"flex",justifyContent:"flex-end",marginTop:i.spacing.md},""),children:(0,H.Y)(w.B,{componentId:"mlflow.gateway.edit-endpoint.starter-code.try-in-browser",type:"primary",onClick:g,children:(0,H.Y)(b.A,{id:"r2dcrJ",defaultMessage:"Try in Browser"})})}),(0,H.Y)(w.M,{componentId:"mlflow.gateway.edit-endpoint.try-it-modal",visible:s,onCancel:()=>d(!1),title:(0,H.Y)(b.A,{id:"/UWNW9",defaultMessage:"Query endpoint"}),footer:null,size:"wide",children:(0,H.Y)("div",{css:we,children:(0,H.Y)(pe,{description:(0,H.Y)(b.A,{id:"b9zfzK",defaultMessage:"Edit the request body below and click Send request to call the endpoint."}),requestTooltipContent:(0,H.Y)(b.A,{id:"embiKN",defaultMessage:"JSON body sent to the endpoint. Edit the fields and click Send request."}),componentId:"mlflow.gateway.edit-endpoint.try-it-modal.request-tooltip",tryItRequestUrl:A,tryItDefaultBody:Y,tryItOptions:S},`try-it-${t}-${c}`)})})]})};var be=i(24344);const Ae=({endpoint:e,existingEndpoints:n,onNameUpdate:i,isSubmitting:t=!1})=>{const{theme:a}=(0,w.u)(),o=(0,A.A)(),[r,s]=(0,l.useState)(!1),[d,c]=(0,l.useState)(""),[u,g]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1),f=()=>{s(!1),c(""),g(null)};return(0,H.FD)(H.FK,{children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:a.spacing.xs}
1,""),children:[(0,H.Y)(w.T.Title,{level:2,withoutMargins:!0,children:null===e||void 0===e?void 0:e.name}),(0,H.Y)(w.s,{componentId:"mlflow.gateway.edit-endpoint.name-edit-tooltip",content:o.formatMessage({id:"nBKx6U",defaultMessage:"Edit endpoint name"}),children:(0,H.Y)(w.B,{componentId:"mlflow.gateway.edit-endpoint.name-edit-button",size:"small",type:"tertiary",icon:(0,H.Y)(w.fJ,{}),onClick:()=>{var n;c(null!==(n=null===e||void 0===e?void 0:e.name)&&void 0!==n?n:""),g(null),s(!0)},disabled:t,"aria-label":o.formatMessage({id:"5umyLP",defaultMessage:"Edit endpoint name"})})})]}),(0,H.Y)(w.M,{componentId:"mlflow.gateway.edit-endpoint-name-modal",title:o.formatMessage({id:"AawxF/",defaultMessage:"Edit Endpoint Name"}),visible:r,onCancel:f,onOk:async()=>{const t=(i=>{if(!i.trim())return o.formatMessage({id:"Y73UT6",defaultMessage:"Endpoint name is required"});if(!(0,be.j8)(i))return o.formatMessage({id:"dzIz7c",defaultMessage:"Name can only contain letters, numbers, underscores, hyphens, and dots. Spaces and special characters are not allowed."});const t=null===n||void 0===n?void 0:n.filter(n=>n.endpoint_id!==(null===e||void 0===e?void 0:e.endpoint_id));return null!==t&&void 0!==t&&t.some(e=>e.name===i)?o.formatMessage({id:"gVz/1j",defaultMessage:"An endpoint with this name already exists"}):null})(d);if(t)g(t);else if(d!==(null===e||void 0===e?void 0:e.name)){m(!0);try{await i(d),f()}catch(a){g(a.message||"Failed to update endpoint name")}finally{m(!1)}}else f()},okText:o.formatMessage({id:"8DoNdT",defaultMessage:"Save"}),cancelText:o.formatMessage({id:"hHNj31",defaultMessage:"Cancel"}),confirmLoading:p,okButtonProps:{disabled:!d.trim()||d===(null===e||void 0===e?void 0:e.name)},size:"normal",children:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:a.spacing.md},""),children:[u&&(0,H.Y)(x.Alert,{componentId:"mlflow.gateway.edit-endpoint-name-modal.error",type:"error",message:u,closable:!1}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:a.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,children:(0,H.Y)(b.A,{id:"FHJ1NN",defaultMessage:"Endpoint Name"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:a.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"iT2I8i",defaultMessage:"The name is used in the endpoint URL. Only letters, numbers, underscores, hyphens, and dots are allowed."})}),(0,H.Y)(x.Input,{componentId:"mlflow.gateway.edit-endpoint-name-modal.name-input",value:d,onChange:e=>{c(e.target.value),u&&g(null)},placeholder:o.formatMessage({id:"AanBxl",defaultMessage:"my-endpoint"}),validationState:u?"error":void 0,autoFocus:!0})]})]})})]})};var Ye=i(13249),Se=i(76103);var Ie={name:"ti75j2",styles:"margin:0"};const Me=({experimentId:e,tooltipLinkUrlBuilder:n,additionalControls:i,filters:t})=>{const{theme:a}=(0,w.u)();return(0,H.FD)("div",{children:[(0,H.FD)("div",{css:(0,v.AH)({marginBottom:a.spacing.md},""),children:[(0,H.Y)(w.T.Title,{level:3,css:Ie,children:(0,H.Y)(b.A,{id:"pjCmlG",defaultMessage:"Usage"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginTop:a.spacing.xs},""),children:(0,H.Y)(b.A,{id:"rdK1v3",defaultMessage:"Monitor endpoint usage and performance metrics"})}),(0,H.Y)(w.T.Link,{componentId:"mlflow.gateway.endpoint.usage.view-full-dashboard",href:(0,Se.Xw)(`#/experiments/${e}/overview`),css:(0,v.AH)({display:"inline-block",marginTop:a.spacing.xs},""),children:(0,H.Y)(b.A,{id:"hR27A2",defaultMessage:"View full dashboard"})})]}),(0,H.Y)(Ye.Y,{experimentIds:[e],showTokenStats:!0,additionalControls:i,tooltipLinkUrlBuilder:n,tooltipLinkText:n?(0,H.Y)(b.A,{id:"V+4GZQ",defaultMessage:"View logs for this period"}):void 0,filters:t})]})};var ke=i(67162),_e=i(55082);const Te=[];var Ce=i(13603),De=i(63116),Fe=i(29806),He=i(20695);const Ee={BEFORE:'Receives {{ inputs }} (the incoming request). Answer yes to pass, no to block/sanitize.\nExample: "Is {{ inputs }} free of profanity? Answer yes if it is safe, no if it contains profanity."',AFTER:'Receives {{ inputs }} (the request) and {{ outputs }} (the response). Answer yes to pass, no to block/sanitize.\nExample: "Does {{ outputs }} correctly answer {{ inputs }}? Answer yes if it does, no if it is off-topic or incorrect."'},Re=(e,n)=>e.trim()?"BEFORE"===n?e.includes("{{ outputs }}")?"{{ outputs }} is not available in Pre-LLM Guardrails \u2014 the LLM has not run yet":e.includes("{{ inputs }}")?null:"Pre-LLM Guardrails instructions must reference {{ inputs }}":e.includes("{{ inputs }}")||e.includes("{{ outputs }}")?null:"Post-LLM Guardrails instructions must reference {{ inputs }} or {{ outputs }}
1":null,Ne=({stage:e,onChange:n})=>{const{theme:i}=(0,w.u)(),t=(0,A.A)();return(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{bold:!0,css:(0,v.AH)({display:"block",fontSize:i.typography.fontSizeLg,marginBottom:i.spacing.xs},""),children:(0,H.Y)(b.A,{id:"SAXxAc",defaultMessage:"Stage"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:i.spacing.sm,fontSize:i.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"N5IyPh",defaultMessage:"Click on a stage to choose when this guardrail runs."})}),(0,H.Y)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,padding:`${i.spacing.md}px ${i.spacing.lg}px`,border:`1px solid ${i.colors.border}`,borderRadius:i.borders.borderRadiusMd},""),children:["Request","BEFORE","LLM","AFTER","Response"].map((a,o)=>{const r="BEFORE"===a||"AFTER"===a,s=r&&a===e,l="BEFORE"===a?t.formatMessage({id:"jpvRrY",defaultMessage:"Pre-LLM Guardrails"}):"AFTER"===a?t.formatMessage({id:"f3cOoh",defaultMessage:"Post-LLM Guardrails"}):a;return(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:i.spacing.sm},""),children:[o>0&&(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:i.typography.fontSizeSm},""),children:">"}),r?(0,H.Y)("div",{role:"option","aria-selected":s,onClick:()=>n(a),onKeyDown:e=>"Enter"===e.key&&n(a),tabIndex:0,css:(0,v.AH)({padding:`${i.spacing.xs}px ${i.spacing.sm}px`,borderRadius:i.borders.borderRadiusMd,border:`1.5px dashed ${s?i.colors.actionPrimaryBackgroundDefault:i.colors.border}`,cursor:"pointer",fontWeight:s?i.typography.typographyBoldFontWeight:"normal",color:s?i.colors.actionPrimaryBackgroundDefault:i.colors.textPrimary,whiteSpace:"nowrap",userSelect:"none","&:hover":{borderColor:i.colors.actionPrimaryBackgroundDefault,color:i.colors.actionPrimaryBackgroundDefault}},""),children:l}):(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:i.typography.fontSizeSm,whiteSpace:"nowrap"},""),children:l})]},a)})})]})};var Le={name:"4zleql",styles:"display:block"};const Be=({componentId:e,value:n,icon:i,title:t,description:a,selected:o,onSelect:r})=>{const{theme:s}=(0,w.u)(),d=(0,w.g)({componentType:w.D.Button,componentId:e,analyticsEvents:[w.f.OnClick]}),c=(0,l.useCallback)(e=>{d.onClick(e),r(n)},[d,r,n]);return(0,H.FD)("div",{role:"option","aria-selected":o,onClick:c,onKeyDown:e=>"Enter"===e.key&&r(n),tabIndex:0,css:(0,v.AH)({display:"flex",alignItems:"flex-start",gap:s.spacing.sm,padding:s.spacing.md,borderRadius:s.borders.borderRadiusMd,border:`2px solid ${o?s.colors.actionPrimaryBackgroundDefault:s.colors.border}`,cursor:"pointer","&:hover":{borderColor:s.colors.actionPrimaryBackgroundDefault}},""),children:[(0,H.Y)("div",{css:(0,v.AH)({color:s.colors.textSecondary,flexShrink:0},""),children:i}),(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{bold:!0,css:Le,children:t}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",fontSize:s.typography.fontSizeSm},""),children:a})]})]})},ze=({action:e,onActionChange:n})=>{const{theme:i}=(0,w.u)(),t=[{value:"VALIDATION",componentId:"mlflow.gateway.guardrails.action-option.validation",icon:(0,H.Y)(w.fq,{}),title:(0,H.Y)(b.A,{id:"qbtNJS",defaultMessage:"Block"}),description:(0,H.Y)(b.A,{id:"rt9clc",defaultMessage:"Return a 400 error with the guardrail name and reason. The original request or response is not passed through."})},{value:"SANITIZATION",componentId:"mlflow.gateway.guardrails.action-option.sanitization",icon:(0,H.Y)(w.gV,{}),title:(0,H.Y)(b.A,{id:"aw59+I",defaultMessage:"Sanitize"}),description:(0,H.Y)(b.A,{id:"wqv2gd",defaultMessage:"Redact or mask flagged content, then allow the request to continue."})}];return(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{bold:!0,css:(0,v.AH)({display:"block",fontSize:i.typography.fontSizeLg,marginBottom:i.spacing.sm},""),children:(0,H.Y)(b.A,{id:"tBHYWH",defaultMessage:"Action"})}),(0,H.Y)("div",{css:(0,v.AH)({display:"grid",gridTemplateColumns:"1fr 1fr",gap:i.spacing.md},""),children:t.map(({value:i,componentId:t,icon:a,title:o,description:r})=>(0,H.Y)(Be,{componentId:t,value:i,icon:a,title:o,description:r,selected:e===i,onSelect:n},i))})]})};var Oe={name:"fxp7t8",styles:"flex:1;min-width:0"};const Pe=({componentId:e,type:n,onClick:i})=>{const{theme:t}=(0,w.u)(),a=(0,w.g)({componentType:w.D.Button,componentId:e,analyticsEvents:[w.f.OnClick]}),o=(0,l.useCallback)(e=>{a.onClick(e),i()},[a,i]);return(0,H.FD)("div",{role:"option","aria-selected":!1,onClick:o,onKeyDown:e=>"Enter"===e.key&&i(),tabIndex:0,css:(0,v.AH)({display:"flex",alignItems:"flex-start",ga
1p:t.spacing.sm,padding:t.spacing.md,borderRadius:t.borders.borderRadiusMd,border:`2px solid ${t.colors.border}`,cursor:"pointer","&:hover":{borderColor:t.colors.actionPrimaryBackgroundDefault},transition:"border-color 0.15s"},""),children:[(0,H.Y)("div",{css:(0,v.AH)({color:t.colors.textSecondary,fontSize:t.typography.fontSizeLg,flexShrink:0},""),children:n.icon}),(0,H.FD)("div",{css:Oe,children:[(0,H.Y)(w.T.Text,{bold:!0,children:n.name}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",fontSize:t.typography.fontSizeSm},""),children:n.description})]})]})};var $e={name:"skgbeu",styles:"display:flex;justify-content:flex-end"},je={name:"unrh3l",styles:"display:flex;justify-content:space-between;width:100%"};const qe=({open:e,onClose:n,onSuccess:i,endpointId:t,experimentId:a})=>{const{theme:o}=(0,w.u)(),r=(0,A.A)(),c=(e=>[{id:"safety",componentId:"mlflow.gateway.guardrails.type-card.safety",name:e.formatMessage({id:"6x1oqv",defaultMessage:"Safety"}),description:e.formatMessage({id:"rBPhzU",defaultMessage:"Detects harmful, offensive, or toxic content in requests and responses."}),icon:(0,H.Y)(w.Y,{}),builtin:!0,scorerClass:Fe.Dw.SAFETY,presetInstructions:De._[Fe.Dw.SAFETY],defaultStage:"AFTER"},{id:"pii",componentId:"mlflow.gateway.guardrails.type-card.pii",name:e.formatMessage({id:"ogHYBU",defaultMessage:"PII Detection"}),description:e.formatMessage({id:"mzmlq2",defaultMessage:"Detects personally identifiable information such as names, emails, and phone numbers."}),icon:(0,H.Y)(w.hZ,{}),builtin:!0,presetInstructions:'You are a PII (Personally Identifiable Information) detector. Analyze the given text for any personal data that could identify an individual, including names, email addresses, phone numbers, physical addresses, social security numbers, credit card numbers, dates of birth, IP addresses, or other identifying information. Your entire response must be a single, raw JSON object with no surrounding text or markdown.\n\nThe JSON object must be structured only using the following format. Do not use any markdown formatting or output additional lines.\n{\n    "rationale": "A concise explanation for your decision. Start each rationale with `Let\'s think step by step`",\n    "result": "The string \'yes\' if the content contains no PII, or \'no\' if PII is detected."\n}\n\n<text>{{ inputs }}</text>',defaultStage:"BEFORE"},{id:"custom",componentId:"mlflow.gateway.guardrails.type-card.custom",name:e.formatMessage({id:"EiFPFP",defaultMessage:"Custom Guardrail"}),description:e.formatMessage({id:"rOj9V6",defaultMessage:"Define your own guardrail with a custom name and instructions."}),icon:(0,H.Y)(w.eb,{}),builtin:!1}])(r),{mutateAsync:p}=(()=>{const e=(0,s.jE)();return(0,g.n)({mutationFn:e=>u.t.createGuardrail(e),onSuccess:()=>{e.invalidateQueries(_e.N.guardrails)}})})(),m=(0,s.jE)(),{data:f=[],isLoading:h,error:y}=(0,d.c)(),[Y,S]=(0,l.useState)(1),[I,M]=(0,l.useState)(""),[k,_]=(0,l.useState)(""),[T,C]=(0,l.useState)(void 0),[D,F]=(0,l.useState)("BEFORE"),[E,R]=(0,l.useState)("VALIDATION"),[N,L]=(0,l.useState)(!1),[B,z]=(0,l.useState)(null);(0,l.useEffect)(()=>{e&&(S(1),M(""),_(""),C(void 0),F("BEFORE"),R("VALIDATION"),z(null))},[e]);const O=(0,l.useCallback)(e=>{_(n=>"AFTER"===e?n.replace(/\{\{\s*inputs\s*\}\}/g,"{{ outputs }}"):n.replace(/\{\{\s*outputs\s*\}\}/g,"{{ inputs }}")),F(e)},[]),P=(0,l.useCallback)(e=>{var n,i;e.builtin?(M(e.name),_(null!==(n=e.presetInstructions)&&void 0!==n?n:""),F(null!==(i=e.defaultStage)&&void 0!==i?i:"BEFORE")):(M(""),_(""));S(2)},[]),$=(0,l.useCallback)(()=>{S(1),z(null)},[]),j=(0,l.useCallback)(async()=>{if(I.trim()&&T){L(!0),z(null);try{const e=f.find(e=>e.name===T);if(!e)throw new Error(r.formatMessage({id:"r0J+Jm",defaultMessage:"Selected guardrail model endpoint is unavailable. Please choose another endpoint."}));const o=I.trim().toLowerCase(),s={name:o,instructions_judge_pydantic_data:{instructions:k.trim(),feedback_value_type:{type:"string",enum:["yes","no"]},model:`gateway:/${T}`}},l=await(0,Ce.S2)(null!==a&&void 0!==a?a:"0",{name:o,serialized_scorer:JSON.stringify(s)}),d=await p({name:I.trim(),scorer_id:l.scorer_id,scorer_version:l.version,stage:D,action:E,..."SANITIZATION"===E?{action_endpoint_id:e.endpoint_id}:{}});await u.t.addGuardrailToEndpoint({endpoint_id:t,guardrail_id:d.guardrail.guardrail_id}
1),m.invalidateQueries(_e.N.guardrails),i(),n()}catch(o){var e;z(null!==(e=null===o||void 0===o?void 0:o.message)&&void 0!==e?e:"Failed to create guardrail")}finally{L(!1)}}},[I,k,T,f,D,E,t,a,p,r,i,n,m]),q=Re(k,D),U=I.trim().length>0&&null===q,G=!(!h&&!y)||f.some(e=>e.endpoint_id!==t),V=G?T?void 0:r.formatMessage({id:"tEX/Gk",defaultMessage:"Select a Guardrail Model endpoint to create this guardrail."}):r.formatMessage({id:"WDmiPW",defaultMessage:"You need another endpoint to use guardrails."}),W=!U||N||!T;return(0,H.FD)(w.M,{componentId:"mlflow.gateway.guardrails.add-modal",title:r.formatMessage({id:"J2IXIT",defaultMessage:"Create Guardrail"}),visible:e,onCancel:n,size:"wide",footer:1===Y?(0,H.Y)("div",{css:$e,children:(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.cancel",onClick:n,children:(0,H.Y)(b.A,{id:"qz9XeG",defaultMessage:"Cancel"})})}):(0,H.FD)("div",{css:je,children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.back",type:"tertiary",icon:(0,H.Y)(w.k,{}),onClick:$,children:(0,H.Y)(b.A,{id:"2XH9oW",defaultMessage:"Back"})}),(0,H.Y)(w.s,{componentId:"mlflow.gateway.guardrails.create-tooltip",content:V,children:(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.create",type:"primary",onClick:j,loading:N,disabled:W,children:(0,H.Y)(b.A,{id:"73n+mN",defaultMessage:"Create Guardrail"})})})]}),children:[1===Y&&(0,H.FD)(H.FK,{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:o.spacing.md},""),children:(0,H.Y)(b.A,{id:"LQVkoY",defaultMessage:"Select the type of guardrail you want to create."})}),(0,H.Y)("div",{css:(0,v.AH)({display:"grid",gridTemplateColumns:"1fr 1fr",gap:o.spacing.md},""),children:c.map(e=>(0,H.Y)(Pe,{componentId:e.componentId,type:e,onClick:()=>P(e)},e.id))})]}),2===Y&&(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:o.spacing.lg},""),children:[(0,H.Y)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:o.spacing.md},""),children:(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:o.spacing.xs},""),children:(0,H.Y)(b.A,{id:"+6406R",defaultMessage:"Name"})}),(0,H.Y)(x.Input,{componentId:"mlflow.gateway.guardrails.config-name",value:I,onChange:e=>M(e.target.value),placeholder:r.formatMessage({id:"VWngGA",defaultMessage:"e.g., PII Detection & Redaction"})})]})}),(0,H.Y)(Ne,{stage:D,onChange:O}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:o.spacing.md},""),children:[(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:o.spacing.xs},""),children:(0,H.Y)(b.A,{id:"gtvp+Q",defaultMessage:"Instructions"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:o.spacing.xs,fontSize:o.typography.fontSizeSm,whiteSpace:"pre-line"},""),children:Ee[D]}),(0,H.Y)(x.Input.TextArea,{componentId:"mlflow.gateway.guardrails.config-instructions",value:k,onChange:e=>_(e.target.value),placeholder:r.formatMessage({id:"oyQRYx",defaultMessage:"Describe what this guardrail should check for..."}),autoSize:{minRows:4,maxRows:10}}),q&&(0,H.Y)(w.T.Text,{color:"error",css:(0,v.AH)({display:"block",marginTop:o.spacing.xs,fontSize:o.typography.fontSizeSm},""),children:q})]}),(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:o.spacing.xs},""),children:(0,H.Y)(b.A,{id:"BsbMZW",defaultMessage:"Guardrail Model"})}),(0,H.Y)(He.L,{componentIdPrefix:"mlflow.gateway.guardrails.config-model",currentEndpointName:T,onEndpointSelect:C,disabled:!G,showCreateButton:!1,excludeEndpointIds:[t]}),!G&&(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginTop:o.spacing.xs,fontSize:o.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"qEq4S6",defaultMessage:"You need another endpoint to use guardrails."})})]})]}),(0,H.Y)(ze,{action:E,onActionChange:R}),B&&(0,H.Y)(w.T.Text,{color:"error",children:B})]})]})};var Ue={name:"unrh3l",styles:"display:flex;justify-content:space-between;width:100%"};const Ge=({open:e,onClose:n,onDelete:i,onSuccess:t,endpointId:a,experimentId:o,guardrailConfig:r})=>{var s,c,g,p;const{theme:m}=(0,w.u)(),f=(0,A.A)(),{data:h=[]}=(0,d.c)(),y=null===r||void 0===r?void 0:r.guardrail,[Y,S]=(0,l.useState)(null!==(s=null===y||void 0===y?void 0:y.stage)&&void 0!==s?s:"BEFORE"),[I,M]=(0,l.useState)(null!==(c=null===y||void 0===y?void 0:y.action)&&void 0!==c?c:"VALIDATION"),[k,_]=(0,l.useState)(""),[T,C]=(0,l.useState)(void 0),[D,F]=(0,l.useState)(!1),[E,R]=(0,l.useState)(null),N=function(e){try{if(e)return JSON.parse(e)}catch{}return null}(null===y||void 0===y||null===(g=y.scorer)||void 0===g?void 0:g.serialized_scorer),L=function(e){var n,i,t;return null!==e&&void 0!==e&&null!==(n=e.instructions_judge_pydantic_data)&&void 0!==n&&n.instructions?e.instructions_judge_pydantic_data.instructions:null!==e&&void 0!==e&&null!==(i=e.builtin_scorer_pydantic_data)&&void 0!==i&&i.instructions?e.builtin_scorer_pydantic_data.instructions:null!==e&&void 0!==e&&e.instructions?e.instructions:null!==e&&void 0!==e&&e.call_source?e.call_source:null!==e&&void 0!==e&&e.builtin_scorer_class?null!==(t=De._[e.builtin_scorer_class])&&void 0!==t?t:e.builtin_scorer_class:""}(N),B=function(e,n){var i,t,a;const o=null===e||void 0===e||null===(i=e.instructions_judge_pydantic_data)||void 0===i?void 0:i.model;if(null===o||void 0===o||!o.startsWith("gateway:/"))return;const r=o.slice(9),s=null!==(t=n.find(e=>e.name===r))&&void 0!==t?t:n.find(e=>e.endpoint_id===r);return null!==(a=null===s||void 0===s?void 0:s.name)&&void 0!==a?a:r}(N,h);(0,l.useEffect)(()=>{e&&y&&(S(y.stage),M(y.action),_(L),C(B),R(null))},[e,y,L,B,h]);const z=y&&(Y!==y.stage||I!==y.action||k!==L||T!==B),O=Re(k,Y),P=(0,l.useCallback)(e=>{_(n=>"AFTER"===e?n.replace(/\{\{\s*inputs\s*\}\}/g,"{{ outputs }}"):n.replace(/\{\{\s*outputs\s*\}\}/g,"{{ inputs }}")),S(e)},[]),$=(0,l.useCallback)(async()=>
1{if(r&&y&&z){F(!0),R(null);try{var e,i,s;let d=null===(e=y.scorer)||void 0===e?void 0:e.scorer_id,c=null===(i=y.scorer)||void 0===i?void 0:i.scorer_version;if(k!==L||T!==B){var l;const e=null!==(l=null===N||void 0===N?void 0:N.name)&&void 0!==l?l:y.name,n=await(0,Ce.S2)(null!==o&&void 0!==o?o:"0",{name:e,serialized_scorer:JSON.stringify({name:e,instructions_judge_pydantic_data:{...null===N||void 0===N?void 0:N.instructions_judge_pydantic_data,instructions:k,feedback_value_type:{type:"string",enum:["yes","no"]},...T?{model:`gateway:/${T}`}:{model:void 0}}})});d=n.scorer_id,c=n.version}if(!d||void 0===c)throw new Error("Cannot update guardrail: scorer information is missing");const g=await u.t.createGuardrail({name:y.name,scorer_id:d,scorer_version:c,stage:Y,action:I,..."SANITIZATION"===I&&T?{action_endpoint_id:null===(s=h.find(e=>e.name===T))||void 0===s?void 0:s.endpoint_id}:{}});await u.t.addGuardrailToEndpoint({endpoint_id:a,guardrail_id:g.guardrail.guardrail_id,execution_order:r.execution_order}),await u.t.removeGuardrailFromEndpoint({endpoint_id:a,guardrail_id:r.guardrail_id}),t(),n()}catch(c){var d;R(null!==(d=null===c||void 0===c?void 0:c.message)&&void 0!==d?d:"Failed to update guardrail")}finally{F(!1)}}},[r,y,z,k,L,T,B,h,N,Y,I,a,o,t,n]),j=(0,l.useCallback)(()=>{r&&(i(r.guardrail_id),n())},[r,i,n]);return r?(0,H.FD)(w.M,{componentId:"mlflow.gateway.guardrails.detail-modal",title:f.formatMessage({id:"uPG7mJ",defaultMessage:"Guardrail: {name}"},{name:null!==(p=null===y||void 0===y?void 0:y.name)&&void 0!==p?p:r.guardrail_id}),visible:e,onCancel:n,size:"wide",footer:(0,H.FD)("div",{css:Ue,children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.detail-delete",danger:!0,onClick:j,children:(0,H.Y)(b.A,{id:"Df9GMB",defaultMessage:"Delete"})}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",gap:m.spacing.sm},""),children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.detail-cancel",onClick:n,children:(0,H.Y)(b.A,{id:"Px7S/2",defaultMessage:"Close"})}),(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.detail-save",type:"primary",onClick:$,loading:D,disabled:!z||D||null!==O,children:(0,H.Y)(b.A,{id:"Q/QcTS",defaultMessage:"Save"})})]})]}),children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:m.spacing.md},""),children:(0,H.Y)(b.A,{id:"Lvcsl4",defaultMessage:"Review and edit the guardrail details, choose placement and action."})}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:m.spacing.lg},""),children:[(0,H.Y)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:m.spacing.md},""),children:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"baseline",gap:m.spacing.sm},""),children:[(0,H.Y)(w.T.Text,{bold:!0,css:(0,v.AH)({fontSize:m.typography.fontSizeLg},""),children:(0,H.Y)(b.A,{id:"SqmrRR",defaultMessage:"Guardrail Details"})}),(null===y||void 0===y?void 0:y.scorer)&&(0,H.FD)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:m.typography.fontSizeSm},""),children:["v",y.scorer.scorer_version]})]})}),(0,H.Y)(Ne,{stage:Y,onChange:P}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:m.spacing.md},""),children:[(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:m.spacing.xs},""),children:(0,H.Y)(b.A,{id:"Bg/LgH",defaultMessage:"Instructions"})}),(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:m.spacing.xs,fontSize:m.typography.fontSizeSm,whiteSpace:"pre-line"},""),children:Ee[Y]}),(0,H.Y)(x.Input.TextArea,{componentId:"mlflow.gateway.guardrails.detail-prompt",value:k,onChange:e=>_(e.target.value),autoSize:{minRows:4,maxRows:10}}),O&&(0,H.Y)(w.T.Text,{color:"error",css:(0,v.AH)({display:"block",marginTop:m.spacing.xs,fontSize:m.typography.fontSizeSm},""),children:O})]}),(0,H.FD)("div",{children:[(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({display:"block",marginBottom:m.spacing.xs},""),children:(0,H.Y)(b.A,{id:"BsbMZW",defaultMessage:"Guardrail Model"})}),(0,H.Y)(He.L,{componentIdPrefix:"mlflow.gateway.guardrails.detail-model",currentEndpointName:T,onEndpointSelect:C,showCreateButton:!1,excludeEndpointIds:[a]})]})]}),(0,H.Y)(ze,{action:I,onActionChange:M}),E&&(0,H.Y)(w.T.Text,{color:"error",children:E})]})]}):null};const Ve=["Request","BEFORE","LLM","AFTER","Response"],We={BEFORE:"Pre-LLM Guardrails",AFTER:"Post-LLM Guardrails"},Ke={BEFORE:"This pre-LLM guardrail runs before the request reaches the LLM",AFTER:"This post-LLM guardrail runs after the LLM response is generated"},Je=({stage:e})=>{const{theme:n}
1=(0,w.u)(),i="BEFORE"===e?n.colors.actionPrimaryBackgroundDefault:n.colors.textValidationSuccess;return(0,H.FD)("div",{css:(0,v.AH)({minWidth:360,padding:n.spacing.xs},""),children:[(0,H.Y)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:n.spacing.xs,marginBottom:n.spacing.sm},""),children:Ve.map((t,a)=>{var o;const r=t===e,s=null!==(o=We[t])&&void 0!==o?o:t;return(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:n.spacing.xs},""),children:[a>0&&(0,H.Y)(w.T.Text,{color:"secondary",css:(0,v.AH)({fontSize:n.typography.fontSizeSm},""),children:">"}),(0,H.Y)("span",{css:(0,v.AH)({padding:`2px ${n.spacing.sm}px`,borderRadius:n.borders.borderRadiusMd,fontSize:n.typography.fontSizeSm,fontWeight:r?n.typography.typographyBoldFontWeight:"normal",color:r?n.colors.white:n.colors.textSecondary,backgroundColor:r?i:"transparent",border:`1px solid ${r?i:"transparent"}`,whiteSpace:"nowrap"},""),children:s})]},t)})}),(0,H.Y)(w.T.Text,{css:(0,v.AH)({fontSize:n.typography.fontSizeSm},""),children:Ke[e]}
1)]})};var Qe={name:"1by9jh9",styles:"flex:0;min-width:40px;max-width:40px"},Xe={name:"1189xqs",styles:"flex:2"},Ze={name:"82a6rk",styles:"flex:1"},en={name:"5psq76",styles:"cursor:default;display:inline-block"},nn={name:"82a6rk",styles:"flex:1"};const tn=({guardrail:e,isSelected:n,onSelectChange:i,onView:t})=>{var a,o,r,s;const{theme:l}=(0,w.u)(),d=null!==(a=null===(o=e.guardrail)||void 0===o?void 0:o.name)&&void 0!==a?a:e.guardrail_id,c=null===(r=e.guardrail)||void 0===r?void 0:r.stage,u=null===(s=e.guardrail)||void 0===s?void 0:s.action,g="BEFORE"===c?"indigo":"AFTER"===c?"teal":"default",p="BEFORE"===c?"Pre-LLM Guardrails":"AFTER"===c?"Post-LLM Guardrails":null!==c&&void 0!==c?c:"\u2014",m="VALIDATION"===u?"coral":"SANITIZATION"===u?"purple":"default",f="VALIDATION"===u?"Block":"SANITIZATION"===u?"Sanitize":null!==u&&void 0!==u?u:"\u2014";return(0,H.FD)(x.TableRow,{children:[(0,H.Y)(x.TableCell,{css:Qe,children:(0,H.Y)(w.aH,{componentId:"mlflow.gateway.guardrails.row-checkbox",isChecked:n,onChange:i})}),(0,H.Y)(x.TableCell,{css:Xe,children:(0,H.Y)("button",{type:"button",css:(0,v.AH)({background:"none",border:"none",padding:0,cursor:"pointer",fontWeight:l.typography.typographyBoldFontWeight,color:l.colors.actionPrimaryBackgroundDefault,fontSize:"inherit","&:hover":{textDecoration:"underline"}},""),onClick:()=>t(e),children:d})}),(0,H.Y)(x.TableCell,{css:Ze,children:"BEFORE"===c||"AFTER"===c?(0,H.FD)(ke.j.Root,{componentId:"mlflow.gateway.guardrails.placement-popover",children:[(0,H.Y)(ke.j.Trigger,{asChild:!0,children:(0,H.Y)("span",{css:en,children:(0,H.Y)(x.Tag,{componentId:"mlflow.gateway.guardrails.stage-tag",color:g,children:p})})}),(0,H.Y)(ke.j.Content,{side:"bottom",align:"start",children:(0,H.Y)(Je,{stage:c})})]}):(0,H.Y)(x.Tag,{componentId:"mlflow.gateway.guardrails.stage-tag",color:g,children:p})}),(0,H.Y)(x.TableCell,{css:nn,children:(0,H.Y)(x.Tag,{componentId:"mlflow.gateway.guardrails.action-tag",color:m,children:f})})]},e.guardrail_id)};var an={name:"1hetg88",styles:"max-width:300px"},on={name:"1by9jh9",styles:"flex:0;min-width:40px;max-width:40px"},rn={name:"1189xqs",styles:"flex:2"},sn={name:"82a6rk",styles:"flex:1"},ln={name:"82a6rk",styles:"flex:1"},dn={name:"1slu30l",styles:"display:flex;align-items:center;justify-content:center;min-height:200px;width:100%;& > div{height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;}"};const cn=({endpointName:e,endpointId:n,experimentId:i})=>{const{theme:t}=(0,w.u)(),a=(0,A.A)(),o=(0,s.jE)(),[r,d]=(0,l.useState)(!1),[p,m]=(0,l.useState)(null),[f,h]=(0,l.useState)(""),[y,Y]=(0,l.useState)({}),[S,I]=(0,l.useState)([]),[M,k]=(0,l.useState)(!1),[_,T]=(0,l.useState)(null),{data:C,isLoading:D,error:F}=(e=>{var n,i;const t=(0,c.I)([..._e.N.guardrails,e],{queryFn:()=>u.t.listEndpointGuardrailConfigs(e),retry:!1,enabled:Boolean(e)});return{data:(0,l.useMemo)(()=>{var e,n;return null!==(e=null===(n=t.data)||void 0===n?void 0:n.configs)&&void 0!==e?e:Te},[null===(n=t.data)||void 0===n?void 0:n.configs]),error:null!==(i=t.error)&&void 0!==i?i:void 0,isLoading:t.isLoading,refetch:t.refetch}})(n),{mutateAsync:E}=(()=>{const e=(0,s.jE)();return(0,g.n)({mutationFn:async e=>{await u.t.removeGuardrailFromEndpoint(e)},onSuccess:()=>{e.invalidateQueries(_e.N.guardrails)}})})(),R=(0,l.useMemo)(()=>C.filter(e=>{var n,i;if(!f.trim())return!0;return(null!==(n=null===(i=e.guardrail)||void 0===i?void 0:i.name)&&void 0!==n?n:e.guardrail_id).toLowerCase().includes(f.trim().toLowerCase())}),[C,f]),N=(0,l.useMemo)(()=>R.filter(e=>y[e.guardrail_id]),[R,y]),L=N.length,B=R.length>0&&L===R.length,z=L>0&&!B,O=(0,l.useCallback)(()=>{Y(B?{}:Object.fromEntries(R.map(e=>[e.guardrail_id,!0])))},[B,R]),P=(0,l.useCallback)(e=>{Y(n=>({...n,[e]:!n[e]}))},[]),$=(0,l.useCallback)(()=>{T(null),I(N)},[N]),j=(0,l.useCallback)(async()=>{k(!0),T(null);try{await Promise.all(S.map(e=>E({endpoint_id:n,guardrail_id:e.guardrail_id}))),Y({}),I([])}catch{T(a.formatMessage({id:"h1VO0z",defaultMessage:"Failed to remove one or more guardrails. Please try again."}))}finally{k(!1)}},[S,E,n,a]),q=(0,l.useCallback)(e=>{T(null),m(null);const n=C.find(n=>n.guardrail_id===e);n&&I([n])},[C]);return D?(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:t.spacing.sm,padding:t.spacing.md},""),children:[(0,H.Y)(w.ah,{size:"small"}),(0,H.Y)(b.A,{id:"vNmXQ2",defaultMessage:"Loading guardrails..."})]}):(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:t.spacing.md},""),children:[F&&(0,H.Y)(x.Alert,{componentId:"mlflow.gateway.guardrails.error",type:"error",message:F.message,closable:!1}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:t.spacing.sm},""),children:[(0,H.Y)(x.Input,{componentId:"mlflow.gateway.guardrails.search",prefix:(0,H.Y)(w.at,{}),placeholder:a.formatMessage({id:"CaIW+m",defaultMessage:"Search guardrails"}),value:f,onChange:e=>h(e.target.value),allowClear:!0,css:an}),(0,H.FD)("div",{css:(0,v.AH)({marginLeft:"auto",display:"flex",gap:t.spacing.sm},""),children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.add",type:"primary",onClick:()=>d(!0),children:(0,H.Y)(b.A,{id:"73n+mN",defaultMessage:"Create Guardrail"})}),(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.delete",danger:!0,disabled:0===L,onClick:$,children:(0,H.Y)(b.A,{id:"b5Aw4a",defaultMessage:"Delete{count, select, 0 {} other { ({count})}}",values:{count:L}})})]})]}),(0,H.FD)(x.Table,{css:(0,v.AH)({minHeight:"unset",borderLeft:`1px solid ${t.colors.border}`,borderRight:`1px solid ${t.colors.border}`,borderTop:`1px solid ${t.colors.border}`,borderBottom:0===R.length?`1px solid ${t.colors.border}`:"none",borderRadius:t.borders.borderRadiusMd,overflow:"hidden"},""),children:[(0,H.FD)(x.TableRow,{isHeader:!0,children:[(0,H.Y)(x.TableCell,{css:on,
1children:(0,H.Y)(w.aH,{componentId:"mlflow.gateway.guardrails.select-all",isChecked:z?null:B,onChange:O})}),(0,H.Y)(x.TableHeader,{componentId:"mlflow.gateway.guardrails.name-header",css:rn,children:(0,H.Y)(b.A,{id:"OExV7v",defaultMessage:"Name"})}),(0,H.Y)(x.TableHeader,{componentId:"mlflow.gateway.guardrails.placement-header",css:sn,children:(0,H.Y)(b.A,{id:"2WOke0",defaultMessage:"Stage"})}),(0,H.Y)(x.TableHeader,{componentId:"mlflow.gateway.guardrails.action-header",css:ln,children:(0,H.Y)(b.A,{id:"R28jzs",defaultMessage:"Action"})})]}),0===R.length?(0,H.Y)("div",{css:dn,children:(0,H.Y)(w.ds,{description:f.trim()?(0,H.Y)(b.A,{id:"VOP7Y5",defaultMessage:"No guardrails match your search."}):(0,H.Y)(b.A,{id:"kaFKCz",defaultMessage:"No guardrails configured. Add a guardrail to protect your LLM endpoint."})})}):R.map(e=>(0,H.Y)(tn,{guardrail:e,isSelected:Boolean(y[e.guardrail_id]),onSelectChange:()=>P(e.guardrail_id),onView:m},e.guardrail_id))]}),(0,H.Y)(qe,{open:r,onClose:()=>d(!1),onSuccess:()=>o.invalidateQueries(_e.N.guardrails),endpointName:e,endpointId:n,experimentId:i}),(0,H.Y)(w.M,{componentId:"mlflow.gateway.guardrails.bulk-remove-modal",title:a.formatMessage({id:"DJsLPv",defaultMessage:"Delete {count, plural, one {guardrail} other {# guardrails}}"},{count:S.length}),visible:S.length>0,onCancel:()=>{M||I([])},footer:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"flex-end",gap:t.spacing.sm},""),children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.bulk-remove-cancel",onClick:()=>I([]),disabled:M,children:(0,H.Y)(b.A,{id:"qz9XeG",defaultMessage:"Cancel"})}),(0,H.Y)(w.B,{componentId:"mlflow.gateway.guardrails.bulk-remove-confirm",type:"primary",danger:!0,onClick:j,loading:M,children:(0,H.Y)(b.A,{id:"Kg1HbP",defaultMessage:"Delete"})})]}),children:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:t.spacing.md},""),children:[_&&(0,H.Y)(x.Alert,{componentId:"mlflow.gateway.guardrails.bulk-remove-error",type:"error",message:_,closable:!1}),(0,H.Y)(w.T.Text,{children:(0,H.Y)(b.A,{id:"bcFuUb",defaultMessage:"Are you sure you want to remove {count, plural, one {this guardrail} other {these # guardrails}}?",values:{count:S.length}})}),S.length>1&&(0,H.Y)("div",{css:(0,v.AH)({maxHeight:200,overflowY:"auto",display:"flex",flexDirection:"column",gap:t.spacing.xs},""),children:S.map(e=>{var n,i;return(0,H.Y)(w.T.Text,{bold:!0,children:null!==(n=null===(i=e.guardrail)||void 0===i?void 0:i.name)&&void 0!==n?n:e.guardrail_id},e.guardrail_id)})})]})}),(0,H.Y)(Ge,{open:!!p,onClose:()=>m(null),onDelete:q,onSuccess:()=>o.invalidateQueries(_e.N.guardrails),endpointId:n,experimentId:i,guardrailConfig:p})]})};var un=i(42072),gn=i(78292),pn=i(79357),mn=i(24507),fn=i(25752),hn=i(71758),yn=i(18105);const vn=e=>{var n,i;return new Set(e.map(e=>{var n;const i=null===(n=e.model_definition)||void 0===n?void 0:n.provider;return"azure"===i?"openai":i})).size<=1?null===(n=e[0])||void 0===n||null===(i=n.model_definition)||void 0===i?void 0:i.provider:void 0},wn=({experimentId:e})=>{const{theme:n}=(0,w.u)(),i=(0,pn.Pz)();return(0,H.FD)(H.FK,{children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:n.spacing.sm},""),children:[(0,H.Y)(mn.$,{excludeOptions:["ALL"]}),(0,H.Y)(t.N_,{componentId:"mlflow.gateway.edit_endpoint.traces_link",to:`/experiments/${e}/traces`,css:(0,v.AH)({color:n.colors.actionPrimaryBackgroundDefault,textDecoration:"none","&:hover":{textDecoration:"underline"}},""),children:(0,H.Y)(b.A,{id:"SHoy6d",defaultMessage:"Open full trace viewer"})})]}),(0,H.Y)(un.v,{experimentIds:[e],disableActions:!0,timeRange:i})]})};var xn={name:"1jyk3dc",styles:"overflow:hidden;display:flex;flex-direction:column;flex:1"},bn={name:"1jyk3dc",styles:"overflow:hidden;display:flex;flex-direction:column;flex:1"},An={name:"1jyk3dc",styles:"overflow:hidden;display:flex;flex-direction:column;flex:1"},Yn={name:"1rb8d7z",styles:"flex:1;display:flex;flex-direction:column;min-height:0"},Sn={name:"82a6rk",styles:"flex:1"},In={name:"ti75j2",styles:"margin:0"},Mn={name:"ti75j2",styles:"margin:0"},kn={name:"kdbhus",styles:"height:100%;display:flex;flex-direction:column"},_n={name:"1e1crzz",styles:"width:280px;flex-shrink:0;position:sticky;top:0;align-self:flex-start"};const Tn=({form:e,isLoadingEndpoint:n,isSubmitting:i,loadError:a,mutationError:o,errorMessage:s,endpoint:d,existingEndpoints:c,isFormComplete:u,hasChanges:g,onSubmit:p,onCancel:m,onNameUpdate:f,onUsageTrackingUpdate:y})=>{const{theme:k}=(0,w.u)(),_=(0,A.A)(),[T,C]=(0,t.ok)(),D=T.get("tab"),F="configuration"===D?"overview":D,E=["overview","guardrails","usage","traces"].includes(F)?F:"overview",R=e.watch("trafficSplitModels"),N=(e.watch("fallbackModels"),e.watch("experimentId")),L=!N&&"guardrails"!==E,B=!N&&"usage"!==E,z=!N&&"traces"!==E,[O,$]=(0,l.useState)([]),j=(0,l.useMemo)(()=>(0,yn.Kg)(O),[O]),q=(0,l.useMemo)(()=>(0,yn.Q1)(O),[O]),U=(0,l.useMemo)(()=>[{value:"state",label:_.formatMessage({id:"0BguZN",defaultMessage:"State"}),valueOptions:yn.Pk.map(e=>({value:e,label:_.formatMessage(fn.Ab[e])}))}],[_]),G=(0,l.useMemo)(()=>
1{if(d)return(e,n,i)=>h.Ay.getEndpointDetailsRoute(d.endpoint_id,{tab:"traces",startTime:new Date(n).toISOString(),endTime:new Date(n+1e3*i).toISOString(),filters:q})},[d,q]),V=R.reduce((e,n)=>e+n.weight,0),W=Math.abs(V-100)<.01,K=(0,l.useMemo)(()=>[...new Set(null===d||void 0===d?void 0:d.model_mappings.map(e=>{var n;return null===(n=e.model_definition)||void 0===n?void 0:n.secret_name}).filter(Boolean))],[null===d||void 0===d?void 0:d.model_mappings]);return n?(0,H.Y)("div",{css:xn,children:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:k.spacing.sm,padding:k.spacing.md},""),children:[(0,H.Y)(w.ah,{size:"small"}),(0,H.Y)(b.A,{id:"RyNXc+",defaultMessage:"Loading endpoint..."})]})}):a?(0,H.Y)("div",{css:bn,children:(0,H.Y)("div",{css:(0,v.AH)({padding:k.spacing.md},""),children:(0,H.Y)(x.Alert,{componentId:"mlflow.gateway.edit-endpoint.error",type:"error",message:null!==(J=a.message)&&void 0!==J?J:"Endpoint not found"})})}):(0,H.FD)("div",{css:An,children:[(0,H.FD)("div",{css:(0,v.AH)({padding:k.spacing.md},""),children:[(0,H.FD)(x.Breadcrumb,{includeTrailingCaret:!0,children:[(0,H.Y)(x.Breadcrumb.Item,{children:(0,H.Y)(t.N_,{componentId:"mlflow.gateway.edit_endpoint.breadcrumb_gateway_link",to:h.Ay.gatewayPageRoute,children:(0,H.Y)(I.H,{})})}),(0,H.Y)(x.Breadcrumb.Item,{children:(0,H.Y)(t.N_,{componentId:"mlflow.gateway.edit_endpoint.breadcrumb_endpoints_link",to:h.Ay.gatewayPageRoute,children:(0,H.Y)(b.A,{id:"eYZ/ZL",defaultMessage:"Endpoints"})})})]}),(0,H.Y)("div",{css:(0,v.AH)({marginTop:k.spacing.sm,display:"flex",justifyContent:"space-between",alignItems:"center"},""),children:(0,H.Y)(Ae,{endpoint:d,existingEndpoints:c,onNameUpdate:f,isSubmitting:i})})]}),o&&(0,H.Y)("div",{css:(0,v.AH)({padding:`0 ${k.spacing.md}px`},""),children:(0,H.Y)(x.Alert,{componentId:"mlflow.gateway.edit-endpoint.mutation-error",closable:!1,message:s,type:"error",css:(0,v.AH)({marginBottom:k.spacing.md},"")})}),(0,H.FD)(w.ht.Root,{componentId:"mlflow.gateway.endpoint.tabs",valueHasNoPii:!0,value:E,onValueChange:e=>{C(n=>(n.set("tab",e),n),{replace:!0})},css:Yn,children:[(0,H.Y)("div",{css:(0,v.AH)({paddingLeft:k.spacing.md,paddingRight:k.spacing.md},""),children:(0,H.FD)(w.ht.List,{children:[(0,H.Y)(w.ht.Trigger,{value:"overview",children:(0,H.Y)(b.A,{id:"9MHcPE",defaultMessage:"Overview"})}),L?(0,H.Y)(w.s,{componentId:"mlflow.gateway.endpoint.guardrails-tab-tooltip",content:_.formatMessage({id:"d2b9xa",defaultMessage:"Enable Usage Tracking in the Overview tab to configure guardrails"}),children:(0,H.Y)(w.ht.Trigger,{value:"guardrails",disabled:!0,children:(0,H.Y)(b.A,{id:"Vjha2S",defaultMessage:"Guardrails"})})}):(0,H.Y)(w.ht.Trigger,{value:"guardrails",children:(0,H.Y)(b.A,{id:"Vjha2S",defaultMessage:"Guardrails"})}),B?(0,H.Y)(w.s,{componentId:"mlflow.gateway.endpoint.usage-tab-tooltip",content:_.formatMessage({id:"VnnPrX",defaultMessage:"Enable Usage Tracking in the Overview tab to view usage metrics"}),children:(0,H.Y)(w.ht.Trigger,{value:"usage",disabled:!0,children:(0,H.Y)(b.A,{id:"0pY/4R",defaultMessage:"Usage"})})}):(0,H.Y)(w.ht.Trigger,{value:"usage",children:(0,H.Y)(b.A,{id:"0pY/4R",defaultMessage:"Usage"})}),z?(0,H.Y)(w.s,{componentId:"mlflow.gateway.endpoint.traces-tab-tooltip",content:_.formatMessage({id:"8mP5Mz",defaultMessage:"Enable Usage Tracking in the Overview tab to view logs"}),children:(0,H.Y)(w.ht.Trigger,{value:"traces",disabled:!0,children:(0,H.Y)(b.A,{id:"t/59XU",defaultMessage:"Logs"})})}):(0,H.Y)(w.ht.Trigger,{value:"traces",children:(0,H.Y)(b.A,{id:"t/59XU",defaultMessage:"Logs"})})]})}),(0,H.FD)("div",{css:(0,v.AH)({flex:1,display:"flex",gap:k.spacing.md,padding:`${k.spacing.md}px`,overflow:"auto",backgroundColor:k.colors.backgroundPrimary},""),children:[(0,H.FD)("div",{css:Sn,children:[(0,H.Y)(w.ht.Content,{value:"overview",children:(0,H.Y)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:k.spacing.lg},""),children:((n,i)=>{const t=null===d||void 0===d||null===(n=d.tags)||void 0===n||null===(i=n.find(e=>e.key===me.ku))||void 0===i?void 0:i.value,a=me.jk.includes(t)?t:void 0;return(0,H.FD)(H.FK,{children:[!a&&(0,H.FD)("div",{css:(0,v.AH)({padding:k.spacing.md,border:`1px solid ${k.colors.border}`,borderRadius:k.borders.borderRadiusMd,backgroundColor:k.colors.backgroundSecondary},""),children:[(0,H.Y)(w.T.Title,{level:3,css:In,children:(0,H.Y)(b.A,{id:"prRya4",defaultMessage:"Model"})}),(0,H.FD)("div",{css:(0,v.AH)({marginTop:k.spacing.md,padding:k.spacing.md,border:`1px solid ${k.colors.border}`,borderRadius:k.borders.borderRadiusMd,backgroundColor:k.colors.backgroundPrimary},""),children:[(0,H.Y)(w.T.Title,{level:4,css:Mn,children:(0,H.Y)(b.A,{id:"uANtE/",defaultMessage:"Primary Model"})}),(0,H.Y)("div",{css:(0,v.AH)({marginTop:k.spacing.md},""),children:(0,H.Y)(r.xI,{control:e.control,name:"trafficSplitModels",render:({field:e})=>(0,H.Y)(P,{value:e.value,onChange:e.onChange,componentId:"mlflow.gateway.edit-endpoint.traffic-split"})})})]}),(0,H.Y)(r.xI,{control:e.control,name:"fallbackModels",render:({field:e})=>(0,H.Y)(te,{value:e.value,onChange:e.onChange,componentId:"mlflow.gateway.edit-endpoint.fallback"})})]}),d&&(a?(0,H.Y)(ye,{endpointName:d.name,codingAgent:a}):(0,H.Y)(xe,{endpointName:d.name,provider:vn(d.model_mappings)}))]})})()})}),(0,H.Y)(w.ht.Content,{value:"guardrails",children:d&&(0,H.Y)(cn,{endpointName:d.name,endpointId:d.endpoint_id,experimentId:N})}),(0,H.Y)(w.ht.Content,{value:"usage",children:N&&(0,H.Y)(Me,{experimentId:N,tooltipLinkUrlBuilder:G,additionalControls:(0,H.Y)(hn.o,{filters:O,setFilters:$,columnOptions:U}),filters:j})}),(0,H.Y)(w.ht.Content,{value:"traces",css:kn,children:N&&(0,H.Y)(gn.k,{children:(0,H.Y)(wn,{experimentId:N})})})]}),"overview"===E&&d&&(0,H.Y)("div",{css:_n,children:(0,H.Y)(M.v,{title:_.formatMessage({id:"Nhr
1kEN",defaultMessage:"Gateway Endpoint Details"}),children:(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:k.spacing.md},""),children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:k.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,color:"secondary",css:(0,v.AH)({fontSize:k.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"53j9+9",defaultMessage:"Date created"})}),(0,H.Y)(w.T.Text,{css:(0,v.AH)({fontSize:k.typography.fontSizeSm},""),children:_.formatDate(new Date(d.created_at),{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"})})]}),K.length>0&&(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:k.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,color:"secondary",css:(0,v.AH)({fontSize:k.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"OnZkIA",defaultMessage:"{count, plural, =1 {API key} other {API keys}}",values:{count:K.length}})}),K.map(e=>(0,H.Y)(t.N_,{componentId:"mlflow.gateway.edit-endpoint.api-key-link",to:Y.Ay.getSettingsSectionRoute(S.k6),css:(0,v.AH)({fontSize:k.typography.fontSizeSm,color:k.colors.actionPrimaryBackgroundDefault,textDecoration:"none","&:hover":{textDecoration:"underline"}},""),children:e},e))]}),(0,H.FD)("div",{css:(0,v.AH)({display:"flex",flexDirection:"column",gap:k.spacing.xs},""),children:[(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:k.spacing.xs},""),children:[(0,H.Y)(w.T.Text,{bold:!0,color:"secondary",css:(0,v.AH)({fontSize:k.typography.fontSizeSm},""),children:(0,H.Y)(b.A,{id:"Dz/+6s",defaultMessage:"Usage tracking"})}),(0,H.Y)(w.eA,{componentId:"mlflow.gateway.edit-endpoint.usage-tracking-info",content:_.formatMessage({id:"FZL3HX",defaultMessage:"When enabled, all requests to this endpoint will be logged as traces. This allows you to monitor usage, debug issues, and analyze performance."})})]}),(0,H.Y)(r.xI,{control:e.control,name:"usageTracking",render:({field:e})=>(0,H.FD)("div",{css:(0,v.AH)({display:"flex",alignItems:"center",gap:k.spacing.sm},""),children:[(0,H.Y)(x.Switch,{componentId:"mlflow.gateway.edit-endpoint.usage-tracking.toggle",checked:e.value,onChange:e=>{y(e)},disabled:i,"aria-label":"Enable usage tracking"}),(0,H.Y)(w.T.Text,{css:(0,v.AH)({fontSize:k.typography.fontSizeSm},""),children:e.value?(0,H.Y)(b.A,{id:"37ReeZ",defaultMessage:"On"}):(0,H.Y)(b.A,{id:"X3Uuiw",defaultMessage:"Off"})})]})})]})]})})})]})]}),g&&"overview"===E&&(0,H.FD)("div",{css:(0,v.AH)({display:"flex",justifyContent:"flex-end",gap:k.spacing.sm,padding:k.spacing.md,borderTop:`1px solid ${k.colors.border}`,flexShrink:0},""),children:[(0,H.Y)(w.B,{componentId:"mlflow.gateway.edit-endpoint.cancel",onClick:m,children:(0,H.Y)(b.A,{id:"qz9XeG",defaultMessage:"Cancel"})}),(0,H.Y)(w.s,{componentId:"mlflow.gateway.edit-endpoint.save-tooltip",content:!u&&R.length>0&&!W?_.formatMessage({id:"3YddwH",defaultMessage:"Traffic split percentages must total 100%"}):u?void 0:_.formatMessage({id:"Lw+dTL",defaultMessage:"Please configure at least one model in traffic split"}),children:(0,H.Y)(w.B,{componentId:"mlflow.gateway.edit-endpoint.save",type:"primary",onClick:e.handleSubmit(p),loading:i,disabled:!u,children:(0,H.Y)(b.A,{id:"NVDxng",defaultMessage:"Save changes"})})})]})]});var J},Cn=(0,a.X)(o.A.mlflowServices.EXPERIMENTS,()=>{const{endpointId:e}=(0,t.g)(),{form:n,isLoadingEndpoint:i,isSubmitting:a,loadError:o,mutationError:s,endpoint:l,existingEndpoints:d,isFormComplete:c,hasChanges:u,handleSubmit:g,handleCancel:p,handleNameUpdate:m,handleUsageTrackingUpdate:h}=y(null!==e&&void 0!==e?e:"");return(0,H.Y)(r.Op,{...n,children:(0,H.Y)(Tn,{form:n,isLoadingEndpoint:i,isSubmitting:a,loadError:o,mutationError:s,errorMessage:(0,f.m)(s),endpoint:l,existingEndpoints:d,isFormComplete:c,hasChanges:u,onSubmit:g,onCancel:p,onNameUpdate:m,onUsageTrackingUpdate:h})})})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.