1"use strict";(globalThis.webpackChunk_mlflow_mlflow=globalThis.webpackChunk_mlflow_mlflow||[]).push([[9239],{5993(e,o,t){t.d(o,{A:()=>i,h:()=>l});var r=t(68073),a=t(8449),n=t(88843);class s{}s.mlflowServices={MODEL_REGISTRY:"Model Registry",EXPERIMENTS:"Experiments",CHAT_SESSIONS:"Chat Sessions",MODEL_SERVING:"Model Serving",RUN_TRACKING:"Run Tracking"};const l=(e,o)=>{if(!(e instanceof a.s))return;const{status:t}=e;let s;const l={status:t};e.getErrorCode()===n.tG.RESOURCE_DOES_NOT_EXIST&&(s=new r.m_(l)),e.getErrorCode()===n.tG.PERMISSION_DENIED&&(s=new r.i_(l)),e.getErrorCode()===n.tG.INTERNAL_ERROR&&(s=new r.PO(l)),e.getErrorCode()===n.tG.INVALID_PARAMETER_VALUE&&(s=new r.v7(l));const i=e.getMessageField();return s&&i&&(s.message=i),s},i=s},23634(e,o,t){t.d(o,{X:()=>d});t(51477);var r=t(88605),a=t(10587),n=t(5460),s=t(63968);function l(){return(0,s.Y)(a.ds,{"data-testid":"fallback",title:(0,s.Y)(n.A,{id:"qAdWdK",defaultMessage:"Error"}),description:(0,s.Y)(n.A,{id:"RzZVxC",defaultMessage:"An error occurred while rendering this component."}),image:(0,s.Y)(a.o,{})})}function i({children:e,customFallbackComponent:o}){function t(e,o){}return o?(0,s.Y)(r.tH,{onError:t,FallbackComponent:o,children:e}):(0,s.Y)(r.tH,{onError:t,fallback:(0,s.Y)(l,{}),children:e})}function d(e,o,t,r){return function(e){return(0,s.Y)(i,{customFallbackComponent:r,children:(0,s.Y)(o,{...e})})}}},9239(e,o,t){t.r(o),t.d(o,{default:()=>be});var r=t(15032),a=t(10587),n=t(67162),s=t(77753),l=t(51477),i=t(74343),d=t(5460),p=t(5993),c=t(23634),m=t(20695),u=t(63968);const{TextArea:g}=s.Input,h=e=>{if(""===e.trim())return;const o=Number(e);return Number.isFinite(o)?o:void 0},f=e=>void 0===e?"":String(e),v=e=>{const o=e.split("\n").map(e=>e.trim()).filter(e=>e.length>0);return o.length>0?o:void 0},y=({value:e,onChange:o})=>{const{theme:t}=(0,a.u)(),n=(0,i.A)(),[p,c]=(0,l.useState)(!1),m=t=>r=>{o({...e,[t]:h(r.target.value)})};return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:t.spacing.md,border:`1px solid ${t.colors.border}`,borderRadius:t.general.borderRadiusBase,padding:t.spacing.md,"& label":{fontWeight:t.typography.typographyRegularFontWeight}},""),children:[(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.temperature",children:(0,u.Y)(d.A,{id:"/jSBSV",defaultMessage:"Temperature"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.temperature",id:"mlflow.playground.params.temperature",type:"number",min:0,max:2,step:.1,value:f(e.temperature),placeholder:n.formatMessage({id:"+yzGfp",defaultMessage:"e.g. 0.7"}),onChange:m("temperature")})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.max_tokens",children:(0,u.Y)(d.A,{id:"K38TFe",defaultMessage:"Max tokens"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.max_tokens",id:"mlflow.playground.params.max_tokens",type:"number",min:1,step:1,value:f(e.max_tokens),placeholder:n.formatMessage({id:"Ev4S86",defaultMessage:"e.g. 512"}),onChange:m("max_tokens")})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.top_p",children:(0,u.Y)(d.A,{id:"RXI71h",defaultMessage:"Top P"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.top_p",id:"mlflow.playground.params.top_p",type:"number",min:0,max:1,step:.05,value:f(e.top_p),placeholder:n.formatMessage({id:"ofL8Me",defaultMessage:"e.g. 1.0"}),onChange:m("top_p")})]}),(0,u.FD)("button",{type:"button",onClick:()=>c(e=>!e),"aria-expanded":p,css:(0,r.AH)({alignSelf:"flex-start",border:0,background:"transparent",padding:0,display:"inline-flex",alignItems:"center",gap:t.spacing.xs,cursor:"pointer",color:t.colors.textPrimary,fontSize:t.typography.fontSizeMd,fontWeight:t.typography.typographyBoldFontWeight,"&:hover":{color:t.colors.textPrimary}},""),children:[p?(0,u.Y)(a.E,{}):(0,u.Y)(a.j,{}),(0,u.Y)(d.A,{id:"iQAdpx",defaultMessage:"Advanced"})]}),p&&(0,u.FD)(u.FK,{children:[(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.top_k",children:(0,u.Y)(d.A,{id:"Jfryx4",defaultMessage:"Top K"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.top_k",id:"mlflow.playground.params.top_k",type:"number",min:1,step:1,value:f(e.top_k),placeholder:n.formatMessage({id:"5sy3VL",defaultMessage:"e.g. 40"}),onChange:m("top_k")})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.presence_penalty",children:(0,u.Y)(d.A,{id:"1yIbZj",defaultMessage:"Presence penalty"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.presence_penalty",id:"mlflow.playground.params.presence_penalty",type:"number",min:-2,max:2,step:.1,value:f(e.presence_penalty),placeholder:n.formatMessage({id:"W7x1CI",defaultMessage:"e.g. 0.0"}),onChange:m("presence_penalty")})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.frequency_penalty",children:(0,u.Y)(d.A,{id:"mBgoBC",defaultMessage:"Frequency penalty"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.params.frequency_penalty",id:"mlflow.playground.params.frequency_penalty",type:"number",min:-2,max:2,step:.1,value:f(e.frequency_penalty),placeholder:n.formatMessage({id:"CZWYoV",defaultMessage:"e.g. 0.0"}),onChange:m("frequency_penalty")})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.params.stop",children:(0,u.Y)(d.A,{id:"W2PfF7",defaultMessage:"Stop sequences"})}),(0,u.Y)(g,{componentId:"mlflow.playground.params.stop",id:"mlflow.playground.params.stop",value:(y=e.stop,(null!==y&&void 0!==y?y:[]).join("\n")),onChange:t=>{o({...e,stop:v(t.target.value)})},autoSize:{minRows:1,maxRows:6},placeholder:n.formatMessage({id:"Pvyd3e",defaultMessage:"One sequence per line"})}),(0,u.Y)(a.T.Hint,{children:(0,u.Y)(d.A,{id:"5m5Oqw",defaultMessage:"The model stops generating when it produces any of these strings."})})]})]})]});var y},{TextArea:x}=s.Input,Y=[{value:"text",label:"Text"},{value:"json_object",label:"JSON"},{value:"json_schema",label:"JSON schema"}],w=({type:e,onTypeChange:o,schemaText:t,onSchemaChange:n,schemaError:l})=>{const{theme:p}=(0,a.u)(),c=(0,i.A)();return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.md},""),children:[(0,u.Y)(s.SegmentedControlGroup,{componentId:"mlflow.playground.response_format.type",name:"mlflow.playground.response_format.type",size:"small",value:e,onCh
1ange:e=>o(e.target.value),children:Y.map(({value:e,label:o})=>(0,u.Y)(s.SegmentedControlButton,{value:e,children:o},e))}),"json_schema"===e&&(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.response_format.schema",children:(0,u.Y)(d.A,{id:"PuVisU",defaultMessage:"Schema"})}),(0,u.Y)(x,{componentId:"mlflow.playground.response_format.schema",id:"mlflow.playground.response_format.schema",value:t,onChange:e=>n(e.target.value),autoSize:{minRows:4,maxRows:16},placeholder:c.formatMessage({id:"JUuOks",defaultMessage:"e.g. {example}"},{example:'{\n "name": "weather_report",\n "schema": {\n "type": "object",\n "properties": {\n "location": { "type": "string" },\n "temperature": { "type": "number" }\n },\n "required": ["location", "temperature"]\n },\n "strict": true\n}'}),css:(0,r.AH)({fontFamily:"monospace",fontSize:p.typography.fontSizeSm},"")}),l&&(0,u.Y)(s.FormUI.Message,{type:"error",message:l})]})]})};var _=t(29942);const b=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\s*\}\}/g,T=e=>{const o=[];for(const t of e){const e=t.content.matchAll(b);for(const t of e)o.push(t[1])}return(0,_.uniq)(o)},A=e=>{if(!e.trim())return!0;try{const o=JSON.parse(e);return Array.isArray(o)&&0===o.length}catch{return!1}},{TextArea:S}=s.Input,M=[{value:"none",label:"None"},{value:"auto",label:"Auto"},{value:"required",label:"Required"}],F=({value:e,onChange:o,error:t,toolChoice:n,onToolChoiceChange:l})=>{const{theme:p}=(0,a.u)(),c=(0,i.A)();return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.md},""),children:[(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.tools.tool_choice",children:(0,u.Y)(d.A,{id:"k0sV3p",defaultMessage:"Tool choice"})}),(0,u.Y)(s.SegmentedControlGroup,{componentId:"mlflow.playground.tools.tool_choice",id:"mlflow.playground.tools.tool_choice",name:"mlflow.playground.tools.tool_choice",size:"small",value:n,onChange:e=>l(e.target.value),children:M.map(({value:e,label:o})=>(0,u.Y)(s.SegmentedControlButton,{value:e,children:o},e))})]}),"none"!==n&&(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.tools.input",children:(0,u.Y)(d.A,{id:"+dueuC",defaultMessage:"JSON Tool Definition"})}),(0,u.Y)(S,{componentId:"mlflow.playground.tools.input",id:"mlflow.playground.tools.input",value:e,onChange:e=>o(e.target.value),autoSize:{minRows:4,maxRows:16},placeholder:c.formatMessage({id:"kGVN6k",defaultMessage:"e.g. {example}"},{example:'[\n {\n "type": "function",\n "function": {\n "name": "get_weather",\n "description": "Get the weather in a given location",\n "parameters": {\n "type": "object",\n "properties": {\n "location": { "type": "string" }\n },\n "required": ["location"]\n }\n }\n }\n]'}),css:(0,r.AH)({fontFamily:"monospace",fontSize:p.typography.fontSizeSm},"")}),A(e)?(0,u.Y)(s.FormUI.Message,{type:"error",message:c.formatMessage({id:"um/4MQ",defaultMessage:"Add at least one tool definition"})}):t&&(0,u.Y)(s.FormUI.Message,{type:"error",message:t})]})]})};const C=e=>({border:0,background:"none",padding:0,display:"inline-flex",cursor:"pointer",color:e.colors.textSecondary,"&:hover":{color:e.colors.textPrimary}}),D=e=>({display:"flex",alignItems:"center",gap:e.spacing.xs});var k={name:"1eclne9",styles:"max-width:360px"},I={name:"1eclne9",styles:"max-width:360px"},N={name:"1eclne9",styles:"max-width:360px"};const P=({value:e,onChange:o,toolsText:t,onToolsChange:l,toolsError:p,toolChoice:c,onToolChoiceChange:m,responseFormatType:g,onResponseFormatTypeChange:h,responseFormatSchemaText:f,onResponseFormatSchemaChange:v,responseFormatSchemaError:x})=>{const{theme:Y}=(0,a.u)(),_=(0,i.A)();return(0,u.FD)(s.Drawer.Root,{children:[(0,u.Y)(s.Drawer.Trigger,{children:(0,u.Y)(a.B,{componentId:"mlflow.playground.params.drawer.trigger",icon:(0,u.Y)(a.ia,{}),"aria-label":_.formatMessage({id:"k/76Sq",defaultMessage:"Open model parameters"}),children:(0,u.Y)(d.A,{id:"hh+/og",defaultMessage:"Settings"})})}),(0,u.Y)(s.Drawer.Content,{componentId:"mlflow.playground.params.drawer",width:420,title:(0,u.FD)("span",{css:(0,r.AH)({display:"inline-flex",alignItems:"center",gap:Y.spacing.xs,fontSize:Y.typography.fontSizeXl,fontWeight:Y.typography.typographyBoldFontWeight,lineHeight:Y.typography.lineHeightXl},""),children:[(0,u.Y)(a.ia,{}),(0,u.Y)(d.A,{id:"qGL2Jy",defaultMessage:"Settings"})]}),children:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:Y.spacing.sm},""),children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"7MRrPu",defaultMessage:"Configure how the model handles your messages, tools, and structured responses."})}),(0,u.Y)(n.S,{size:"sm"}),(0,u.FD)("div",{css:D(Y),children:[(0,u.Y)(a.T.Title,{level:4,withoutMargins:!0,children:(0,u.Y)(d.A,{id:"cIW5zg",defaultMessage:"Parameters"})}),(0,u.FD)(n.j.Root,{componentId:"mlflow.playground.params.section.parameters_help",children:[(0,u.Y)(n.j.Trigger,{"aria-label":_.formatMessage({id:"zt66ty",defaultMessage:"About sampling parameters"}),css:C(Y),children:(0,u.Y)(a.ez,{})}),(0,u.FD)(n.j.Content,{align:"start",css:k,children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"rj4nd8",defaultMessage:"Sampling controls. Adjust how creative or deterministic the model's responses are. Leave a field blank to use the provider's default. Some parameters may not be supported by the provider you are using."})}),(0,u.Y)(n.j.Arrow,{})]})]})]}
1),(0,u.Y)(y,{value:e,onChange:o}),(0,u.Y)(n.S,{size:"md"}),(0,u.FD)("div",{css:D(Y),children:[(0,u.Y)(a.T.Title,{level:4,withoutMargins:!0,children:(0,u.Y)(d.A,{id:"4qjOWx",defaultMessage:"Tools"})}),(0,u.FD)(n.j.Root,{componentId:"mlflow.playground.params.section.tools_help",children:[(0,u.Y)(n.j.Trigger,{"aria-label":_.formatMessage({id:"cto1kL",defaultMessage:"About tool definitions"}),css:C(Y),children:(0,u.Y)(a.ez,{})}),(0,u.FD)(n.j.Content,{align:"start",css:I,children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"+asYF/",defaultMessage:"Have the model call functions you define. Tool choice strategies:"})}),(0,u.FD)("ul",{css:(0,r.AH)({margin:`${Y.spacing.xs}px 0 0`,paddingLeft:Y.spacing.lg},""),children:[(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"None"})," ",(0,u.Y)(d.A,{id:"zehip9",defaultMessage:"\u2014 never call a tool (default)."})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"Auto"})," ",(0,u.Y)(d.A,{id:"5kc6dO",defaultMessage:"\u2014 model decides whether to call a tool."})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"Required"})," ",(0,u.Y)(d.A,{id:"oJg/Kk",defaultMessage:"\u2014 model must call a tool."})]})]}),(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,css:(0,r.AH)({marginTop:Y.spacing.xs},""),children:(0,u.Y)(d.A,{id:"F6YQTG",defaultMessage:"Pick Auto or Required to enter the JSON tool definitions."})}),(0,u.Y)(n.j.Arrow,{})]})]})]}),(0,u.Y)("div",{css:(0,r.AH)({border:`1px solid ${Y.colors.border}`,borderRadius:Y.general.borderRadiusBase,padding:Y.spacing.md},""),children:(0,u.Y)(F,{value:t,onChange:l,error:p,toolChoice:c,onToolChoiceChange:m})}),(0,u.Y)(n.S,{size:"md"}),(0,u.FD)("div",{css:D(Y),children:[(0,u.Y)(a.T.Title,{level:4,withoutMargins:!0,children:(0,u.Y)(d.A,{id:"5U3LXq",defaultMessage:"Response format"})}),(0,u.FD)(n.j.Root,{componentId:"mlflow.playground.params.section.response_format_help",children:[(0,u.Y)(n.j.Trigger,{"aria-label":_.formatMessage({id:"kItpVi",defaultMessage:"About response formats"}),css:C(Y),children:(0,u.Y)(a.ez,{})}),(0,u.FD)(n.j.Content,{align:"start",css:N,children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"weYjQS",defaultMessage:"Constrain how the model formats its output:"})}),(0,u.FD)("ul",{css:(0,r.AH)({margin:`${Y.spacing.xs}px 0 0`,paddingLeft:Y.spacing.lg},""),children:[(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"Text"})," ",(0,u.Y)(d.A,{id:"z0hCh+",defaultMessage:"\u2014 model's natural-language response."})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"JSON"})," ",(0,u.Y)(d.A,{id:"VrVqLn",defaultMessage:"\u2014 model returns valid JSON."})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"JSON schema"})," ",(0,u.Y)(d.A,{id:"fXYUCP",defaultMessage:"\u2014 model output conforms to the schema you provide."})]})]}),(0,u.Y)(n.j.Arrow,{})]})]})]}),(0,u.Y)(w,{type:g,onTypeChange:h,schemaText:f,onSchemaChange:v,schemaError:x})]})})]})},R=({onOpen:e})=>{const o=(0,i.A)();return(0,u.Y)(a.B,{componentId:"mlflow.playground.load_from_registry",icon:(0,u.Y)(a.bM,{}),onClick:e,"aria-label":o.formatMessage({id:"/RFfvj",defaultMessage:"Load prompt"}),children:(0,u.Y)(d.A,{id:"u5B9TA",defaultMessage:"Load prompt"})})},E=({onOpen:e,disabled:o})=>{const t=(0,i.A)();return(0,u.Y)(a.B,{componentId:"mlflow.playground.save_to_registry",icon:(0,u.Y)(a.gq,{}),onClick:e,disabled:o,"aria-label":t.formatMessage({id:"IDk8d+",defaultMessage:"Save prompt"}),children:(0,u.Y)(d.A,{id:"XfsPd4",defaultMessage:"Save prompt"})})},{TextArea:j}=s.Input,O=({messages:e,value:o,onChange:t})=>{const{theme:n}=(0,a.u)(),l=(0,i.A)(),d=T(e),p=e=>r=>{t({...o,[e]:r.target.value})};return(0,u.Y)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:n.spacing.md},""),children:d.map(e=>{var t;const r=`mlflow.playground.variables.input.${e}`;return(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:r,children:e}),(0,u.Y)(j,{componentId:"mlflow.playground.variables.input",id:r,value:null!==(t=o[e])&&void 0!==t?t:"",onChange:p(e),autoSize:{minRows:1,maxRows:8},placeholder:l.formatMessage({id:"WpqCm4",defaultMessage:"Value for {name}"},{name:e})})]},e)})})},q=({messages:e,value:o,onChange:t})=>{const{theme:n}=(0,a.u)(),p=(0,i.A)(),c=(0,l.useMemo)(()=>T(e),[e]),m=(0,u.Y)(d.A,{id:"9vN4bY",defaultMessage:"Variables{count, plural, =0 {} other { ({count})}}",values:{count:c.length}});return(0,u.FD)(s.Drawer.Root,{children:[(0,u.Y)(s.Drawer.Trigger,{children:(0,u.Y)(a.B,{componentId:"mlflow.playground.variables.drawer.trigger",icon:(0,u.Y)(a.cL,{}),"aria-label":p.formatMessage({id:"3EoT6S",defaultMessage:"Open variable values"}),children:m})}),(0,u.Y)(s.Drawer.Content,{componentId:"mlflow.playground.variables.drawer",title:(0,u.FD)("span",{css:(0,r.AH)({display:"inline-flex",alignItems:"center",gap:n.spacing.xs,fontSize:n.typography.fontSizeXl,fontWeight:n.typography.typographyBoldFontWeight,lineHeight:n.typography.lineHeightXl},""),children:[(0,u.Y)(a.cL,{}),(0,u.Y)(d.A,{id:"e/mGnD",defaultMessage:"Variables"})]}),children:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:n.spacing.md},""),children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"DOC1AW",defaultMessage:"Use {example} to create reusable variables. Values entered below replace the placeholders on submit, while your templates stay unchanged for reuse with different inputs.",values:{example:(0,u.Y)(a.T.Text,{code:!0,children:"{{ name }}"})}})}),(0,u.Y)(O,{messages:e,value:o,onChange:t})]})})]})},H=({endpointName:e,onEndpointSelect:o,params:t,onParamsChange:n,toolsText:s,onToolsChange:l,toolsError:i,toolChoice:d,onToolChoiceChange:p,responseFormatType:c,onResponseFormatTypeChange:g,responseFormatSchemaText:h,onResponseFormatSchemaChange:f,responseFormatSchemaError:v,messages:y,variables:x,onVariablesChange:Y,onOpenRegistry:w,onOpenSave:_,saveDisabled:b})=>{const{theme:T}=(0,a.u)();return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",alignItems:"center",gap:T.spacing.sm,flexWrap:"wrap"},""),children:[(0,u.Y)(m.L,{componentIdPrefix:"mlflow.playground.endpoint-selector",currentEndpointName:e,onEndpointSelect:o,showCreateButton:!0,triggerMaxWidth:400}),(0,u.Y)(P,{value:t,onChange:n,toolsText:s,onToolsChange:l,toolsError:i,toolChoice:d,onToolChoiceChange:p,responseFormatType:c,onResponseFormatTypeChange:g,responseFormatSchemaText:h,onResponseFormatSchemaChange:f,responseFormatSchemaError:v}),(0,u.Y)(q,{messages:y,value:x,onChange:Y}),(0,u.Y)(R,{onOpen:w}),(0,u.Y)(E,{onOpen:_,disabled:b})]})};var L=t(76260);const{TextArea:U}=s.Input,z="mlflow.playground.prompt_input",J=["system","user","assistant"],V=e=>e[0].toUpperCase()+e.slice(1);var $={name:"1d3w5wq",styles:"width:100%"},B={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},K={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},W={name:"1eclne9",styles:"max-width:360px"};const G=({messages:e,onChange:o})=>{const{theme:t}=(0,a.u)(),l=(0,i.A)(),p=(t,r)=>{o(e.map((e,o)=>
1o===t?{...e,...r}:e))},c=t=>(0,u.Y)(a.B,{componentId:"mlflow.playground.prompt_input.remove",size:"small",icon:(0,u.Y)(a.n,{}),"aria-label":l.formatMessage({id:"FBlbEZ",defaultMessage:"Remove message"}),onClick:()=>(t=>{o(e.filter((e,o)=>o!==t))})(t)});return(0,u.FD)(s.Space,{direction:"vertical",size:"middle",css:$,children:[0===e.length&&(0,u.Y)(a.T.Hint,{children:(0,u.Y)(d.A,{id:"4PquPn",defaultMessage:"Add a message to send to the endpoint."})}),e.map((e,o)=>{var s,i,m;return(0,u.Y)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:t.spacing.xs},""),"data-testid":`mlflow.playground.prompt_input.message.${e.role}`,children:"assistant"===e.role?(0,u.FD)(u.FK,{children:[(0,u.FD)("div",{css:B,children:[(0,u.Y)(a.T.Text,{css:(0,r.AH)({color:t.colors.textSecondary,fontSize:t.typography.fontSizeSm},""),children:V(e.role)}),c(o)]}),(0,u.Y)("div",{css:(0,r.AH)({border:`1px solid ${t.colors.border}`,borderRadius:t.general.borderRadiusBase,padding:t.spacing.md,backgroundColor:t.colors.backgroundSecondary,overflow:"auto"},""),children:(0,u.Y)(L.V,{children:e.content})}),e.usage&&(0,u.Y)(a.T.Hint,{children:(0,u.Y)(d.A,{id:"fqdOQi",defaultMessage:"Tokens \u2014 input: {input}, output: {output}, total: {total}",values:{input:null!==(s=e.usage.prompt_tokens)&&void 0!==s?s:"\u2014",output:null!==(i=e.usage.completion_tokens)&&void 0!==i?i:"\u2014",total:null!==(m=e.usage.total_tokens)&&void 0!==m?m:"\u2014"}})})]}):(0,u.FD)(u.FK,{children:[(0,u.FD)("div",{css:K,children:[(0,u.FD)(a.dr.Root,{children:[(0,u.Y)(a.dr.Trigger,{asChild:!0,children:(0,u.FD)("button",{type:"button","aria-label":l.formatMessage({id:"1tVKvm",defaultMessage:"Change message role"}),css:(0,r.AH)({border:0,background:"transparent",padding:0,display:"inline-flex",alignItems:"center",gap:t.spacing.xs,cursor:"pointer",color:t.colors.textSecondary,fontSize:t.typography.fontSizeSm,"&:hover":{color:t.colors.textPrimary}},""),children:[V(e.role),(0,u.Y)(a.E,{css:(0,r.AH)({fontSize:t.typography.fontSizeSm},"")})]})}),(0,u.Y)(a.dr.Content,{align:"start",children:(0,u.Y)(a.dr.RadioGroup,{componentId:`${z}.role.group`,value:e.role,onValueChange:e=>p(o,{role:e}),children:J.map(e=>(0,u.FD)(a.dr.RadioItem,{value:e,children:[(0,u.Y)(a.dr.ItemIndicator,{}),V(e)]},e))})})]}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",alignItems:"center",gap:t.spacing.xs},""),children:[(0,u.FD)(n.j.Root,{componentId:"mlflow.playground.prompt_input.role_help",children:[(0,u.Y)(n.j.Trigger,{"aria-label":l.formatMessage({id:"ye3pSE",defaultMessage:"About message roles"}),css:(0,r.AH)({border:0,background:"none",padding:0,display:"inline-flex",cursor:"pointer",color:t.colors.textSecondary,"&:hover":{color:t.colors.textPrimary}},""),children:(0,u.Y)(a.ez,{})}),(0,u.FD)(n.j.Content,{align:"end",css:W,children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"0vwlO5",defaultMessage:"Each message has a role that tells the model who is speaking:"})}),(0,u.FD)("ul",{css:(0,r.AH)({margin:`${t.spacing.xs}px 0 0`,paddingLeft:t.spacing.lg},""),children:[(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"System"})," ",(0,u.Y)(d.A,{id:"SG4oPe",defaultMessage:"\u2014 instructions or persona for the model (e.g. {example}).",values:{example:(0,u.Y)(a.T.Text,{code:!0,children:"You are a helpful assistant"})}})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"User"})," ",(0,u.Y)(d.A,{id:"Lwk6Dz",defaultMessage:"\u2014 what the human is asking. This is the typical input."})]}),(0,u.FD)("li",{children:[(0,u.Y)(a.T.Text,{bold:!0,children:"Assistant"})," ",(0,u.Y)(d.A,{id:"wuhLAU",defaultMessage:"\u2014 what the model has previously said. Useful for priming with example responses."})]})]}),(0,u.Y)(n.j.Arrow,{})]})]}),c(o)]})]}),(0,u.Y)(U,{componentId:"mlflow.playground.prompt_input.content",value:e.content,onChange:e=>p(o,{content:e.target.value}),autoSize:{minRows:3,maxRows:12},placeholder:l.formatMessage({id:"2ikLTU",defaultMessage:"Type a message"})})]})},o)}),(0,u.Y)(a.B,{componentId:`${z}.add`,icon:(0,u.Y)(a.ai,{}),onClick:()=>{o([...e,{role:"user",content:""}])},children:(0,u.Y)(d.A,{id:"gF1WQp",defaultMessage:"Add message"})})]})};var X=t(23170),Q=t(15153),Z=t(46182);const ee=["system","user","assistant"],oe=e=>{const o=(e=>{var o;const t=null!==(o=(0,X.dv)(e))&&void 0!==o?o:"";if((0,X.f5)(e)){const e=(0,X.yC)(t);return e?e.map(e=>{return{role:(o=e.role,ee.includes(o)?e.role:"user"),content:e.content};var o}):[]}return[{role:"user",content:t}]})(e),t=(0,X.f5)(e)?X.Xs:X.Qk,r=(0,X.RJ)(e.tags),a=(0,X.uX)(e.tags),n="string"===typeof a&&a.trim().length>0;if(!r&&!n)return{messages:o,settings:null,promptName:e.name,versionLabel:e.version,promptType:t};const s={};return r&&(void 0!==r.temperature&&(s.temperature=r.temperature),void 0!==r.max_tokens&&(s.max_tokens=r.max_tokens),void 0!==r.top_p&&(s.top_p=r.top_p),void 0!==r.top_k&&(s.top_k=r.top_k),void 0!==r.frequency_penalty&&(s.frequency_penalty=r.frequency_penalty),void 0!==r.presence_penalty&&(s.presence_penalty=r.presence_penalty),Array.isArray(r.stop_sequences)&&r.stop_sequences.length>0&&(s.stop=r.stop_sequences)),{messages:o,settings:{params:s,responseFormatType:n?"json_schema":"text",responseFormatSchemaText:n?a:""},promptName:e.name,versionLabel:e.version,promptType:t}};const te=["temperature","max_tokens","top_p","top_k","frequency_penalty","presence_penalty","stop_sequences"];var re={name:"1d3w5wq",styles:"width:100%"},ae={name:"1d3w5wq",styles:"width:100%"},ne={name:"1u1vtoj",styles:"text-transform:uppercase;letter-spacing:0.5px"},se={name:"1r0lug3",styles:"min-width:72px"},le={name:"1u1vtoj",styles:"text-transform:uppercase;letter-spacing:0.5px"};const ie=({visible:e,onCancel:o,onLoad:t})=>{const n=(0,i.A)(),{theme:p}=(0,a.u)(),[c,m]=(0,l.useState)(void 0),[g,h]=(0,l.useState)(void 0),{data:f,isLoading:v,error:y}=(0,Z.V)(),{data:x,isLoading:Y,error:w}=(0,Q.i)({promptName:null!==c&&void 0!==c?c:""},{enabled:Boolean(c)}),_=(0,l.useMemo)(()=>{var e;return null!==(e=null===x||void 0===x?void 0:x.versions)&&void 0!==e?e:[]},[x]),b=(0,l.useMemo)(()=>_.find(e=>e.version===g),[_,g]),T=(0,l.useMemo)(()=>b?oe(b):null,[b]),A=(0,l.useMemo)(()=>b?(0,X.RJ)(b.tags):void 0,[b]),S=(0,l.useMemo)(()=>
1{if(!b)return!1;const e=(0,X.uX)(b.tags);return"string"===typeof e&&e.trim().length>0},[b]),M=e=>{m(e),h(void 0)};return(0,u.Y)(a.M,{componentId:"mlflow.playground.prompt_registry_picker",visible:e,onCancel:()=>{m(void 0),h(void 0),o()},title:(0,u.FD)("span",{css:(0,r.AH)({display:"inline-flex",alignItems:"center",gap:p.spacing.xs},""),children:[(0,u.Y)(a.bM,{}),(0,u.Y)(d.A,{id:"p+urWV",defaultMessage:"Load prompt from registry"})]}),okText:(0,u.Y)(d.A,{id:"WGe+QH",defaultMessage:"Load"}),okButtonProps:{disabled:!T},onOk:()=>{T&&(t(T),m(void 0),h(void 0))},cancelText:(0,u.Y)(d.A,{id:"o66/ZA",defaultMessage:"Cancel"}),size:"wide",children:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.md},""),children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"fRJE/2",defaultMessage:"Load a saved prompt to replace the current playground messages, and apply any settings stored with it."})}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.prompt_registry_picker.prompt",children:(0,u.Y)(d.A,{id:"tUgCAM",defaultMessage:"Prompt"})}),(0,u.FD)(s.DialogCombobox,{componentId:"mlflow.playground.prompt_registry_picker.prompt",label:n.formatMessage({id:"tUgCAM",defaultMessage:"Prompt"}),modal:!1,value:c?[c]:void 0,children:[(0,u.Y)(s.DialogComboboxTrigger,{id:"mlflow.playground.prompt_registry_picker.prompt",css:re,allowClear:!0,placeholder:n.formatMessage({id:"SYa+JC",defaultMessage:"Select a prompt"}),withInlineLabel:!1,onClear:()=>M("")}),(0,u.Y)(s.DialogComboboxContent,{loading:v,maxHeight:320,matchTriggerWidth:!0,children:!v&&(0,u.Y)(s.DialogComboboxOptionList,{children:(0,u.Y)(s.DialogComboboxOptionListSearch,{autoFocus:!0,children:(null!==f&&void 0!==f?f:[]).map(e=>(0,u.Y)(a.aw,{value:e.name,onChange:e=>M(e),checked:c===e.name,children:e.name},e.name))})})})]}),y&&(0,u.Y)(s.FormUI.Message,{type:"error",message:y.message})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.prompt_registry_picker.version",children:(0,u.Y)(d.A,{id:"Gxl8pl",defaultMessage:"Version"})}),(0,u.FD)(s.DialogCombobox,{componentId:"mlflow.playground.prompt_registry_picker.version",label:n.formatMessage({id:"Gxl8pl",defaultMessage:"Version"}),modal:!1,value:g?[g]:void 0,children:[(0,u.Y)(s.DialogComboboxTrigger,{id:"mlflow.playground.prompt_registry_picker.version",css:ae,allowClear:!0,disabled:!c||Y,placeholder:n.formatMessage({id:"SFfu70",defaultMessage:"Select a version"}),withInlineLabel:!1,onClear:()=>h(void 0)}),(0,u.Y)(s.DialogComboboxContent,{loading:Y,maxHeight:320,matchTriggerWidth:!0,children:!Y&&(0,u.Y)(s.DialogComboboxOptionList,{children:_.map(e=>(0,u.Y)(a.aw,{value:e.version,onChange:e=>h(e),checked:g===e.version,children:`v${e.version}`},e.version))})})]}),w&&(0,u.Y)(s.FormUI.Message,{type:"error",message:w.message})]}),T&&(0,u.FD)(u.FK,{children:[(0,u.Y)("div",{css:(0,r.AH)({borderTop:`1px solid ${p.colors.border}`},""),role:"separator","aria-hidden":"true"}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.md,border:`1px solid ${p.colors.border}`,borderRadius:p.general.borderRadiusBase,padding:p.spacing.md},""),children:[(0,u.Y)(a.T.Title,{level:3,withoutMargins:!0,css:(0,r.AH)({borderBottom:`1px solid ${p.colors.border}`,paddingBottom:p.spacing.xs},""),children:(0,u.Y)(d.A,{id:"DxHEXN",defaultMessage:"Preview"})}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.sm},""),children:[(0,u.Y)(a.T.Text,{size:"sm",color:"secondary",bold:!0,css:ne,children:(0,u.Y)(d.A,{id:"Qb78hE",defaultMessage:"Messages"})}),(0,u.Y)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.xs,maxHeight:240,overflowY:"auto",paddingRight:p.spacing.xs},""),children:0===T.messages.length?(0,u.Y)(a.T.Text,{color:"secondary",children:(0,u.Y)(d.A,{id:"RBHuOR",defaultMessage:"(no messages)"})}):T.messages.map((e,o)=>{return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",gap:p.spacing.sm,alignItems:"baseline"},""),children:[(0,u.Y)(a.T.Text,{bold:!0,css:se,children:e.role}),(0,u.Y)(a.T.Text,{color:"secondary",children:(t=e.content,n=120,t.length>n?`${t.slice(0,n)}\u2026`:t)})]},`${e.role}-${o}`);var t,n})}),!(0,X.f5)(b)&&(0,u.Y)(s.Alert,{componentId:"mlflow.playground.prompt_registry_picker.text_prompt_hint",type:"info",closable:!1,message:(0,u.Y)(d.A,{id:"OH0TQo",defaultMessage:"This is a text-typed prompt. It will load as a
1single user message."})})]}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.sm},""),children:[(0,u.Y)(a.T.Text,{size:"sm",color:"secondary",bold:!0,css:le,children:(0,u.Y)(d.A,{id:"KpFPCX",defaultMessage:"Settings"})}),null===T.settings?(0,u.Y)(a.T.Text,{color:"secondary",children:(0,u.Y)(d.A,{id:"E5GtUd",defaultMessage:"No settings stored with this version"})}):(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:p.spacing.xs},""),children:[te.map(e=>{const o=null===A||void 0===A?void 0:A[e];return void 0===o?null:Array.isArray(o)?0===o.length?null:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",gap:p.spacing.sm},""),children:[(0,u.FD)(a.T.Text,{bold:!0,children:[X.Mz[e],":"]}),(0,u.Y)(a.T.Text,{color:"secondary",children:o.join(", ")})]},e):(0,u.FD)("div",{css:(0,r.AH)({display:"flex",gap:p.spacing.sm},""),children:[(0,u.FD)(a.T.Text,{bold:!0,children:[X.Mz[e],":"]}),(0,u.Y)(a.T.Text,{color:"secondary",children:String(o)})]},e)}),S&&(0,u.FD)("div",{css:(0,r.AH)({display:"flex",gap:p.spacing.sm},""),children:[(0,u.Y)(a.T.Text,{bold:!0,children:(0,u.Y)(d.A,{id:"eTxi4G",defaultMessage:"Response format:"})}),(0,u.Y)(a.T.Text,{color:"secondary",children:(0,u.Y)(d.A,{id:"/JTye7",defaultMessage:"JSON schema"})})]})]})]})]})]})]})})};var de=t(20193),pe=t(12238);const ce=e=>{const o={};return void 0!==e.temperature&&(o.temperature=e.temperature),void 0!==e.max_tokens&&(o.max_tokens=e.max_tokens),void 0!==e.top_p&&(o.top_p=e.top_p),void 0!==e.top_k&&(o.top_k=e.top_k),void 0!==e.frequency_penalty&&(o.frequency_penalty=e.frequency_penalty),void 0!==e.presence_penalty&&(o.presence_penalty=e.presence_penalty),e.stop&&e.stop.length>0&&(o.stop_sequences=e.stop),Object.keys(o).length>0?o:void 0};const me=/^[a-zA-Z0-9_\-.]+$/;var ue={name:"1u1vtoj",styles:"text-transform:uppercase;letter-spacing:0.5px"},ge={name:"1r0lug3",styles:"min-width:72px"};const he=({visible:e,onCancel:o,messages:t,params:n,responseFormatType:p,responseFormatSchemaText:c,loadedPromptName:m,loadedPromptType:g,onSaved:h})=>{const{theme:f}=(0,a.u)(),v=(0,i.A)(),y=(0,de.jE)(),[x,Y]=(0,l.useState)(m?"existing":"new"),[w,_]=(0,l.useState)(""),[b,T]=(0,l.useState)(""),[A,S]=(0,l.useState)(!0),[M,F]=(0,l.useState)(!1),{mutate:C,error:D,isLoading:k,reset:I}=(0,pe.H)();(0,l.useEffect)(()=>{e&&(Y(m?"existing":"new"),_(""),T(""),S(!0),F(!1),I())},[e,m,I]);const N=m?x:"new",P=(0,l.useMemo)(()=>(e=>e.filter(e=>"assistant"!==e.role).map(e=>({role:e.role,content:e.content.trim()})).filter(e=>e.content.length>0))(t),[t]),R=((e,o,t)=>void 0!==ce(e)||"json_schema"===o&&t.trim().length>0)(n,p,c),E=w.trim(),j=(0,l.useMemo)(()=>"new"!==N?null:E?me.test(E)?null:v.formatMessage({id:"LmHxvf",defaultMessage:"Only alphanumeric characters, underscores, hyphens, and dots are allowed"}):v.formatMessage({id:"InNAAD",defaultMessage:"Name is required"}),[N,E,v]),O="existing"===N?null!==m&&void 0!==m?m:"":E,q=P.length>0,H=q&&!j&&O.length>0&&!k;return(0,u.Y)(a.M,{componentId:"mlflow.playground.save_prompt_version",visible:e,onCancel:o,title:(0,u.FD)("span",{css:(0,r.AH)({display:"inline-flex",alignItems:"center",gap:f.spacing.xs},""),children:[(0,u.Y)(a.gq,{}),(0,u.Y)(d.A,{id:"2aFMT3",defaultMessage:"Save prompt to registry"})]}),okText:(0,u.Y)(d.A,{id:"vtQvcd",defaultMessage:"Save version"}),okButtonProps:{disabled:!H,loading:k},onOk:()=>{if(!H)return;const e=A?ce(n):void 0,o=e?[{key:X.Nb,value:JSON.stringify(e)}]:[],t=A&&"json_schema"===p&&c.trim()?c.trim():void 0,r=1===P.length&&"user"===P[0].role,a="existing"===N&&g===X.Qk&&r?X.Qk:X.Xs,s=a===X.Qk?P[0].content:JSON.stringify(P);C({createPromptEntity:"new"===N,promptName:O,promptType:a,content:s,commitMessage:b.trim()||void 0,tags:o,responseFormatJson:t},{onSuccess:e=>{y.invalidateQueries({queryKey:["prompts_list"]}),y.invalidateQueries({queryKey:["prompt_details",{promptName:O}]}),h({name:O,version:e.version,promptType:a})}})},cancelText:(0,u.Y)(d.A,{id:"dp7Jva",defaultMessage:"Cancel"}),size:"wide",children:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:f.spacing.md},""),children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"tEW/jO",defaultMessage:"Save the current playground messages as a new prompt version in the registry."})}),(null===D||void 0===D?void 0:D.message)&&(0,u.Y)(s.Alert,{componentId:"mlflow.playground.save_prompt_version.error",type:"error",closable:!1,message:D.message}),!q&&(0,u.Y)(s.Alert,{componentId:"mlflow.playground.save_prompt_version.no_messages",type:"warning",closable:!1,message:(0,u.Y)(d.A,{id:"p0FZXy",defaultMessage:"Add at least one non-empty message before saving."})}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{children:(0,u.Y)(d.A,{id:"eEjDU
1Q",defaultMessage:"Destination"})}),m?(0,u.FD)(s.SegmentedControlGroup,{componentId:"mlflow.playground.save_prompt_version.target",name:"mlflow.playground.save_prompt_version.target",value:x,onChange:e=>Y(e.target.value),children:[(0,u.Y)(s.SegmentedControlButton,{value:"existing",children:(0,u.Y)(d.A,{id:"YdxomH",defaultMessage:"New version of {name}",values:{name:m}})}),(0,u.Y)(s.SegmentedControlButton,{value:"new",children:(0,u.Y)(d.A,{id:"mEV+mz",defaultMessage:"New prompt"})})]}):(0,u.Y)(a.T.Text,{color:"secondary",children:(0,u.Y)(d.A,{id:"2ZB29e",defaultMessage:"A new prompt will be created in the registry."})})]}),"new"===N&&(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.save_prompt_version.name",children:(0,u.Y)(d.A,{id:"9+31Wm",defaultMessage:"Prompt name"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.save_prompt_version.name",id:"mlflow.playground.save_prompt_version.name",value:w,onChange:e=>_(e.target.value),onBlur:()=>F(!0),placeholder:v.formatMessage({id:"GWkYrG",defaultMessage:"Provide a unique prompt name"}),validationState:M&&j?"error":void 0}),M&&j&&(0,u.Y)(s.FormUI.Message,{type:"error",message:j})]}),(0,u.FD)("div",{children:[(0,u.Y)(s.FormUI.Label,{htmlFor:"mlflow.playground.save_prompt_version.commit_message",children:(0,u.Y)(d.A,{id:"TTXfdj",defaultMessage:"Commit message (optional)"})}),(0,u.Y)(s.Input,{componentId:"mlflow.playground.save_prompt_version.commit_message",id:"mlflow.playground.save_prompt_version.commit_message",value:b,onChange:e=>T(e.target.value)})]}),R&&(0,u.Y)(a.aH,{componentId:"mlflow.playground.save_prompt_version.include_settings",isChecked:A,onChange:e=>S(e),children:(0,u.Y)(d.A,{id:"HRSBco",defaultMessage:"Save model settings with this version"})}),q&&(0,u.FD)(u.FK,{children:[(0,u.Y)("div",{css:(0,r.AH)({borderTop:`1px solid ${f.colors.border}`},""),role:"separator","aria-hidden":"true"}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:f.spacing.sm,border:`1px solid ${f.colors.border}`,borderRadius:f.general.borderRadiusBase,padding:f.spacing.md},""),children:[(0,u.Y)(a.T.Text,{size:"sm",color:"secondary",bold:!0,css:ue,children:(0,u.Y)(d.A,{id:"CZW5JY",defaultMessage:"Messages"})}),(0,u.Y)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:f.spacing.xs,maxHeight:240,overflowY:"auto",paddingRight:f.spacing.xs},""),children:P.map((e,o)=>{return(0,u.FD)("div",{css:(0,r.AH)({display:"flex",gap:f.spacing.sm,alignItems:"baseline"},""),children:[(0,u.Y)(a.T.Text,{bold:!0,css:ge,children:e.role}),(0,u.Y)(a.T.Text,{color:"secondary",children:(t=e.content,n=120,t.length>n?`${t.slice(0,n)}\u2026`:t)})]},`${e.role}-${o}`);var t,n})})]})]})]})})};var fe=t(26666),ve=t(52821);const ye=async e=>{try{const o=await(0,ve.qP)((0,ve.we)("gateway/mlflow/v1/chat/completions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await o.json()}catch(o){throw await(async e=>{const o=e.response;if(!o||o.bodyUsed)return e;try{var t,r;const a=await o.json(),n="object"===typeof(null===a||void 0===a?void 0:a.detail)&&"string"===typeof(null===(t=a.detail)||void 0===t?void 0:t.message)&&a.detail.message||"string"===typeof(null===a||void 0===a?void 0:a.detail)&&a.detail||"string"===typeof(null===a||void 0===a?void 0:a.message)&&a.message||"object"===typeof(null===a||void 0===a?void 0:a.error)&&"string"===typeof(null===(r=a.error)||void 0===r?void 0:r.message)&&a.error.message||void 0;n&&e instanceof Error&&(e.message=n)}catch{}return e})(o)}};const xe={role:"user",content:""};var Ye={name:"3z2sxu",styles:"display:flex;flex-direction:column;flex:1;overflow:hidden"},we={name:"15yy5cp",styles:"white-space:pre-wrap;word-break:break-word;margin:0;font-family:inherit;max-height:240px;overflow:auto"},_e={name:"1r5gb7q",styles:"display:inline-block"};const be=(0,c.X)(p.A.mlflowServices.EXPERIMENTS,()=>{var e,o;const{theme:t}=(0,a.u)(),p=(0,i.A)(),[c,m]=(0,l.useState)(""),[g,h]=(0,l.useState)([{...xe}]),[f,v]=(0,l.useState)({}),[y,x]=(0,l.useState)({}),[Y,w]=(0,l.useState)(""),[_,S]=(0,l.useState)("none"),[M,F]=(0,l.useState)("text"),[C,D]=(0,l.useState)(""),[k,I]=(0,l.useState)(!1),[N,P]=(0,l.useState)(!1),[R,E]=(0,l.useState)(null),[j,O]=(0,l.useState)(null),[q,L]=(0,l.useState)(null),{mutate:U,error:z,isLoading:J,reset:V}=(0,fe.n)({mutationFn:e=>ye(e)});(0,l.useEffect)(()=>
1{if(!j)return;const e=window.setTimeout(()=>O(null),4e3);return()=>window.clearTimeout(e)},[j]),(0,l.useEffect)(()=>{if(!q)return;const e=window.setTimeout(()=>L(null),4e3);return()=>window.clearTimeout(e)},[q]);const $=(0,l.useMemo)(()=>{if(!Y.trim())return null;try{const e=JSON.parse(Y);return Array.isArray(e)?null:"Tools must be a JSON array"}catch(e){return e instanceof Error?e.message:"Invalid JSON"}},[Y]),B=(0,l.useMemo)(()=>{if("json_schema"!==M)return null;if(!C.trim())return"Schema is required";let e;try{e=JSON.parse(C)}catch(o){return o instanceof Error?o.message:"Invalid JSON"}return"object"!==typeof e||null===e||Array.isArray(e)?"Schema must be a JSON object":null},[M,C]),K=(0,l.useMemo)(()=>{const e=[];c||e.push(p.formatMessage({id:"PS87G1",defaultMessage:"Select a model endpoint"})),(0===g.length||g.some(e=>0===e.content.trim().length))&&e.push(p.formatMessage({id:"jNFx/n",defaultMessage:"Fill in every message"})),"none"!==_&&(A(Y)?e.push(p.formatMessage({id:"wqI7on",defaultMessage:"Add at least one tool definition"})):$&&e.push(p.formatMessage({id:"vwvhCa",defaultMessage:"Fix the Tools JSON: {error}"},{error:$}))),B&&e.push(p.formatMessage({id:"/Ni371",defaultMessage:"Fix the response format schema: {error}"},{error:B}));for(const o of((e,o)=>T(e).filter(e=>{var t;return!(null!==(t=o[e])&&void 0!==t?t:"").trim()}))(g,y))e.push(p.formatMessage({id:"mNYNB1",defaultMessage:"Provide a value for the variable {name}"},{name:o}));return e},[c,g,_,Y,$,B,y,p]),W=0===K.length&&!J,X=()=>{if(!W)return;const e="none"!==_&&Y.trim()?JSON.parse(Y):void 0;let o;"json_object"===M?o={type:"json_object"}:"json_schema"===M&&(o={type:"json_schema",json_schema:{name:"response_schema",schema:JSON.parse(C),strict:!0}});const t=((e,o)=>e.map(e=>({...e,content:e.content.replace(b,(e,t)=>{var r;return null!==(r=o[t])&&void 0!==r?r:""})})))(g,y).map(({role:e,content:o})=>({role:e,content:o}));U({model:c,messages:t,...void 0!==f.temperature&&{temperature:f.temperature},...void 0!==f.max_tokens&&{max_tokens:f.max_tokens},...void 0!==f.top_p&&{top_p:f.top_p},...void 0!==f.top_k&&{top_k:f.top_k},...void 0!==f.presence_penalty&&{presence_penalty:f.presence_penalty},...void 0!==f.frequency_penalty&&{frequency_penalty:f.frequency_penalty},...f.stop&&f.stop.length>0&&{stop:f.stop},...e&&{tools:e},...e&&{tool_choice:_},...o&&{response_format:o}},{onSuccess:e=>{var o,t;const r=null===(o=e.choices)||void 0===o||null===(t=o[0])||void 0===t?void 0:t.message;if(!r)return;const a={...r,content:r.content||"(no text content)",usage:e.usage};h(e=>[...e,a,{...xe}])}})},Q=g.length<=1&&!(null!==(e=g[0])&&void 0!==e&&null!==(o=e.content)&&void 0!==o&&o.trim());return(0,u.FD)("div",{css:Ye,children:[(0,u.Y)(H,{endpointName:c,onEndpointSelect:m,params:f,onParamsChange:v,toolsText:Y,onToolsChange:w,toolsError:$,toolChoice:_,onToolChoiceChange:S,responseFormatType:M,onResponseFormatTypeChange:F,responseFormatSchemaText:C,onResponseFormatSchemaChange:D,responseFormatSchemaError:B,messages:g,variables:y,onVariablesChange:x,onOpenRegistry:()=>I(!0),onOpenSave:()=>P(!0),saveDisabled:Q}),(0,u.Y)(n.S,{size:"sm",shrinks:!1}),(0,u.Y)("div",{css:(0,r.AH)({borderTop:`1px solid ${t.colors.border}`,flexShrink:0},""),role:"separator","aria-hidden":"true"}),(0,u.Y)(n.S,{size:"sm",shrinks:!1}),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:t.spacing.md,flex:1,minHeight:0,overflowY:"auto"},""),children:[(0,u.Y)(G,{messages:g,onChange:h}),J&&(0,u.Y)("div",{css:(0,r.AH)({display:"flex",justifyContent:"center",padding:t.spacing.md},""),children:(0,u.Y)(a.ah,{})}),!J&&z&&(()=>{const e=z.status,o=e?`HTTP ${e} \u2014 ${z.message}`:z.message;return(0,u.Y)(s.Alert,{type:"error",componentId:"mlflow.playground.output.error",closable:!1,message:(0,u.Y)(d.A,{id:"0WTeD+",defaultMessage:"Chat completion failed"}),description:(0,u.Y)("pre",{css:we,children:o})})})(),(0,u.FD)("div",{css:(0,r.AH)({display:"flex",justifyContent:"flex-end",alignItems:"center",gap:t.spacing.sm,paddingTop:t.spacing.md,paddingBottom:t.spacing.md,position:"sticky",bottom:0,backgroundColor:t.colors.backgroundPrimary},""),children:[(0,u.Y)(a.B,{componentId:"mlflow.playground.clear",disabled:Q,onClick:()=>{h([{...xe}]),V()},children:(0,u.Y)(d.A,{id:"EfT7KE",defaultMessage:"Clear conversation"})}),(()=>{const e=(0,u.Y)(a.B,{componentId:"mlflow.playground.submit",type:"primary",icon:(0,u.Y)(a.fW,{}),disabled:!W,loading:J,onClick:X,children:(0,u.Y)(d.A,{id:"3MZ6H+",defaultMessage:"Submit"})});return 0===K.length?e:(0,u.Y)(s.HoverCard,{trigger:(0,u.Y)("span",{css:_e,children:e}),content:(0,u.FD)("div",{css:(0,r.AH)({display:"flex",flexDirection:"column",gap:t.spacing.sm,padding:t.spacing.sm,maxWidth:360},""),children:[(0,u.Y)(a.T.Paragraph,{withoutMargins:!0,children:(0,u.Y)(d.A,{id:"GyyqO1",defaultMessage:"To submit:"})}),(0,u.Y)("ul",{css:(0,r.AH)({margin:`${t.spacing.xs}px 0 0`,paddingLeft:t.spacing.lg},""),children:K.map(e=>(0,u.Y)("li",{children:e},e))})]}),side:"top",align:"end"})})()]})]}),(0,u.Y)(ie,{visible:k,onCancel:()=>I(!1),onLoad:e=>{h(e.messages.length>0?e.messages:[{...xe}]),null!==e.settings&&(v(e.settings.params),F(e.settings.responseFormatType),D(e.settings.responseFormatSchemaText)),I(!1),E({name:e.promptName,version:e.versionLabel,promptType:e.promptType}),O({name:e.promptName,version:e.versionLabel,withSettings:null!==e.settings})}}),(0,u.Y)(he,{visible:N,onCancel:()=>P(!1),messages:g,params:f,responseFormatType:M,responseFormatSchemaText:C,loadedPromptName:null===R||void 0===R?void 0:R.name,loadedPromptType:null===R||void 0===R?void 0:R.promptType,onSaved:({n
1ame:e,version:o,promptType:t})=>{P(!1),E({name:e,version:o,promptType:t}),L({name:e,version:o})}}),j&&(0,u.FD)(s.Notification.Provider,{children:[(0,u.FD)(s.Notification.Root,{severity:"success",componentId:"mlflow.playground.prompt_registry_picker.loaded",children:[(0,u.Y)(s.Notification.Title,{children:j.withSettings?(0,u.Y)(d.A,{id:"075RKh",defaultMessage:"Loaded {name} v{version} with settings",values:{name:j.name,version:j.version}}):(0,u.Y)(d.A,{id:"x5IuGA",defaultMessage:"Loaded {name} v{version}",values:{name:j.name,version:j.version}})}),(0,u.Y)(s.Notification.Close,{componentId:"mlflow.playground.prompt_registry_picker.loaded.close"})]}),(0,u.Y)(s.Notification.Viewport,{})]}),q&&(0,u.FD)(s.Notification.Provider,{children:[(0,u.FD)(s.Notification.Root,{severity:"success",componentId:"mlflow.playground.save_prompt_version.saved",children:[(0,u.Y)(s.Notification.Title,{children:(0,u.Y)(d.A,{id:"iX9mZm",defaultMessage:"Saved {name} v{version} to the registry",values:{name:q.name,version:q.version}})}),(0,u.Y)(s.Notification.Close,{componentId:"mlflow.playground.save_prompt_version.saved.close"})]}),(0,u.Y)(s.Notification.Viewport,{})]})]})})},12339(e,o,t){t.d(o,{M:()=>l});var r=t(68073),a=t(52821),n=t(23170);const s=async({reject:e,response:o,err:t})=>{const a=(0,r.a$)(o),n=a instanceof r.Bk?t:a;if(o)try{var s;const e=null===(s=await o.json())||void 0===s?void 0:s.message;e&&(n.message=e)}catch{}e(n)},l={listRegisteredPrompts:(e,o,t)=>{const r=new URLSearchParams,l=(0,n.Cs)(e);let i=`tags.\`${n.PS}\` = '${n.pY}'`;t&&(i+=` AND tags.\`${n.TV}\` ILIKE '%,${t},%'`),l&&(i+=` AND ${l}`),o&&r.append("page_token",o),r.append("filter",i);const d=["ajax-api/2.0/mlflow/registered-models/search",r.toString()].join("?");return(0,a.AC)({relativeUrl:d,error:s})},setRegisteredPromptTag:(e,o,t)=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/registered-models/set-tag",method:"POST",body:JSON.stringify({key:o,value:t,name:e}),error:s}),deleteRegisteredPromptTag:(e,o)=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/registered-models/delete-tag",method:"DELETE",body:JSON.stringify({key:o,name:e}),error:s}),createRegisteredPrompt:(e,o=[])=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/registered-models/create",method:"POST",body:JSON.stringify({name:e,tags:[{key:n.PS,value:n.pY},...o]}),error:s}),createRegisteredPromptVersion:(e,o=[],t)=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/model-versions/create",method:"POST",body:JSON.stringify({name:e,description:t,source:"dummy-source",tags:[{key:n.PS,value:n.pY},...o]}),error:s}),setRegisteredPromptVersionTag:(e,o,t,r)=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/model-versions/set-tag",method:"POST",body:JSON.stringify({key:t,value:r,name:e,version:o}),error:s}),deleteRegisteredPromptVersionTag:(e,o,t)=>{(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/model-versions/delete-tag",method:"DELETE",body:JSON.stringify({key:t,name:e,version:o}),error:s})},getPromptDetails:e=>{const o=new URLSearchParams;o.append("name",e);const t=["ajax-api/2.0/mlflow/registered-models/get",o.toString()].join("?");return(0,a.AC)({relativeUrl:t,error:s})},getPromptVersions:e=>{const o=new URLSearchParams;o.append("filter",`name='${e}' AND tags.\`${n.PS}\` = '${n.pY}'`);const t=["ajax-api/2.0/mlflow/model-versions/search",o.toString()].join("?");return(0,a.AC)({relativeUrl:t,error:s})},getPromptVersionsForRun:e=>{const o=new URLSearchParams;o.append("filter",`tags.\`${n.PS}\` = '${n.pY}' AND tags.\`${n.xd}\` ILIKE "%${e}%"`);const t=["ajax-api/2.0/mlflow/model-versions/search",o.toString()].join("?");return(0,a.AC)({relativeUrl:t,error:s})},deleteRegisteredPrompt:e=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/registered-models/delete",method:"DELETE",body:JSON.stringify({name:e}),error:s}),deleteRegisteredPromptVersion:(e,o)=>(0,a.AC)({relativeUrl:"ajax-api/2.0/mlflow/model-versions/delete",method:"DELETE",body:JSON.stringify({name:e,version:o}),error:s})}},12238(e,o,t){t.d(o,{H:()=>s});var r=t(26666),a=t(12339),n=t(23170);const s=()=>(0,r.n)({mutationFn:async({promptName:e,promptType:o,createPromptEntity:t,content:r,commitMessage:s,tags:l,promptTags:i=[],responseFormatJson:d})=>{var p;t&&await a.M.createRegisteredPrompt(e,i);const c=d?[{key:n.d3,value:d}]:[],m=await a.M.createRegisteredPromptVersion(e,[{key:n.Dh,value:r},{key:n.$,value:o},...l,...c],s),u=null===m||void 0===m||null===(p=m.model_version)||void 0===p?void 0:p.version;if(!u)throw new Error("Failed to create a new prompt version");return{version:u}}})},15153(e,o,t){t.d(o,{i:()=>s});var r=t(21602),a=t(12339);const n=async({queryKey:e})=>{var o;const[,{promptName:t}]=e,[r,n]=await Promise.all([a.M.getPromptDetails(t),a.M.getPromptVersions(t)]);return{prompt:r.registered_model,versions:null!==(o=n.model_versions)&&void 0!==o?o:[]}},s=({promptName:e},o={})=>{var t;const a=(0,r.I)(["prompt_details",{promptName:e}],{queryFn:n,retry:!1,...o});return{data:a.data,error:null!==(t=a.error)&&void 0!==t?t:void 0,isLoading:a.isLoading,refetch:a.refetch}}},46182(e,o,t){t.d(o,{V:()=>l});var r=t(21602),a=t(51477),n=t(12339);const s=({queryKey:e})=>{const[,{searchFilter:o,pageToken:t,experimentId:r}]=e;return n.M.listRegisteredPrompts(o,t,r)},l=({searchFilter:e,experimentId:o}={})=>{var t,n,l,i;const d=(0,a.useRef)([]),[p,c]=(0,a.useState)(void 0),m=(0,r.I)(["prompts_list",{searchFilter:e,pageToken:p,experimentId:o}],{queryFn:s,retry:!1}),u=(0,a.useCallback)(()=>{var e;d.current.push(p),c(null===(e=m.data)||void 0===e?void 0:e.next_page_token)},[null===(t=m.data)||void 0===t?void 0:t.next_page_token,p]),g=(0,a.useCallback)(()=>{const e=d.current.pop();c(e)},[]);return{data:null===(n=m.data)||void 0===n?void 0:n.registered_models,error:null!==(l=m.error)&&void 0!==l?l:void 0,isLoading:m.isLoading,hasNextPage:void 0!==(null===(i=m.data)||void 0===i?void 0:i.next_page_token),hasPreviousPage:Boolean(p),onNextPage:u,onPreviousPage:g,refetch:m.refetch}}},23170(e,o,t){t.d(o,{$:()=>c,$t:()=>f,Cs:()=>_,Dh:()=>n,Dp:()=>v,Mz:()=>h,Nb:()=>u,PS:()=>l,Qk:()=>d,RJ:()=>b,TV:()=>m,U7:()=>w,V:()=>T,Xs:()=>p,_f:()=>S,d3:()=>g,dv:()=>y,f5:()=>x,pY:()=>i,t0:()=>F,uX:()=>M,xT:()=>A,xd:()=>s,yC:()=>Y});var r=t(37493),a=t(67593);const n="mlflow.prompt.text",s="mlflow.prompt.run_ids",l="mlflow.prompt.is_prompt",i="true",d="text",p="chat",c="_mlflow_prompt_type",m="_mlflow_experiment_ids",u="_mlflow_prompt_model_config",g="_mlflow_prompt_response_format",h={provider:"Provider",model_name:"Model",temperature:"Temperature",max_tokens:"Max Tokens",top_p:"Top P",top_k:"Top K",frequency_penalty:"Frequency Penalty",presence_penalty:"Presence Penalty",stop_sequences:"Stop Sequences"},f="promptVersion";let v=function(e){return e.PREVIEW="preview",e.COMPARE="compare",e.TRACES="traces",e}({});const y=e=>{var o,t;return null===e||void 0===e||null===(o=e.tags)||void 0===o||null===(t=o.find(e=>e.key===n))||void 0===t?void 0:t.value},x=e=>{var o,t;return(null===e||void 0===e||null===(o=e.tags)||void 0===o||null===(t=o.find(e=>e.key===c))||void 0===t?void 0:t.value)===p},Y=e=>{if(!e)return;const o=(0,r.pt)(e);return(e=>Array.isArray(e)&&e.every(e=>(e=>e&&"object"===typeof e&&"string"===typeof e.role&&"string"===typeof e.content)(e)))(o)?o:void 0},w=e=>{const o=e[a.VT];if(!o||!o.value)return[];try{const e=JSON.parse(o.value);if(Array.isArray(e))return e.filter(e=>
1e&&"string"===typeof e.name&&"string"===typeof e.version)}catch(t){}return[]},_=e=>{if(!e)return"";return/(\s+(ILIKE|LIKE)\s+)|=|!=/i.test(e)?e:`name ILIKE '%${e}%'`},b=e=>{const o=null===e||void 0===e?void 0:e.find(e=>e.key===u);if(null!==o&&void 0!==o&&o.value)try{return JSON.parse(o.value)}catch(t){return}},T=e=>{var o,t,r,a,n,s,l,i,d;if(!Object.values(e).some(e=>Boolean(e)))return;const p={},c=null===(o=e.provider)||void 0===o?void 0:o.trim();c&&(p.provider=c);const m=null===(t=e.modelName)||void 0===t?void 0:t.trim();if(m&&(p.model_name=m),null!==(r=e.temperature)&&void 0!==r&&r.trim()){const o=parseFloat(e.temperature);isNaN(o)||(p.temperature=o)}if(null!==(a=e.maxTokens)&&void 0!==a&&a.trim()){const o=parseInt(e.maxTokens,10);isNaN(o)||(p.max_tokens=o)}if(null!==(n=e.topP)&&void 0!==n&&n.trim()){const o=parseFloat(e.topP);isNaN(o)||(p.top_p=o)}if(null!==(s=e.topK)&&void 0!==s&&s.trim()){const o=parseInt(e.topK,10);isNaN(o)||(p.top_k=o)}if(null!==(l=e.frequencyPenalty)&&void 0!==l&&l.trim()){const o=parseFloat(e.frequencyPenalty);isNaN(o)||(p.frequency_penalty=o)}if(null!==(i=e.presencePenalty)&&void 0!==i&&i.trim()){const o=parseFloat(e.presencePenalty);isNaN(o)||(p.presence_penalty=o)}if(null!==(d=e.stopSequences)&&void 0!==d&&d.trim()){const o=e.stopSequences.split(",").map(e=>e.trim()).filter(e=>e.length>0);o.length>0&&(p.stop_sequences=o)}return Object.keys(p).length>0?p:void 0},A=e=>{var o,t;return e?{provider:null!==(o=e.provider)&&void 0!==o?o:"",modelName:null!==(t=e.model_name)&&void 0!==t?t:"",temperature:void 0!==e.temperature?String(e.temperature):"",maxTokens:void 0!==e.max_tokens?String(e.max_tokens):"",topP:void 0!==e.top_p?String(e.top_p):"",topK:void 0!==e.top_k?String(e.top_k):"",frequencyPenalty:void 0!==e.frequency_penalty?String(e.frequency_penalty):"",presencePenalty:void 0!==e.presence_penalty?String(e.presence_penalty):"",stopSequences:e.stop_sequences?e.stop_sequences.join(", "):""}:{}},S=e=>{var o,t,r,a,n,s;const l={};if(null!==(o=e.temperature)&&void 0!==o&&o.trim()){const o=parseFloat(e.temperature);(isNaN(o)||o<0)&&(l.temperature="Temperature must be a number >= 0")}if(null!==(t=e.maxTokens)&&void 0!==t&&t.trim()){const o=parseInt(e.maxTokens,10);(isNaN(o)||o<=0)&&(l.maxTokens="Max tokens must be an integer > 0")}if(null!==(r=e.topP)&&void 0!==r&&r.trim()){const o=parseFloat(e.topP);(isNaN(o)||o<0||o>1)&&(l.topP="Top P must be a number between 0 and 1")}if(null!==(a=e.topK)&&void 0!==a&&a.trim()){const o=parseInt(e.topK,10);(isNaN(o)||o<=0)&&(l.topK="Top K must be an integer > 0")}if(null!==(n=e.frequencyPenalty)&&void 0!==n&&n.trim()){const o=parseFloat(e.frequencyPenalty);(isNaN(o)||o<-2||o>2)&&(l.frequencyPenalty="Frequency penalty must be a number between -2 and 2")}if(null!==(s=e.presencePenalty)&&void 0!==s&&s.trim()){const o=parseFloat(e.presencePenalty);(isNaN(o)||o<-2||o>2)&&(l.presencePenalty="Presence penalty must be a number between -2 and 2")}return l},M=e=>{const o=null===e||void 0===e?void 0:e.find(e=>e.key===g);return(null===o||void 0===o?void 0:o.value)||void 0},F=e=>{const o=null===e||void 0===e?void 0:e.trim();if(!o)return{valid:!0};try{const e=JSON.parse(o);return"object"!==typeof e||null===e||Array.isArray(e)?{valid:!1,error:"Structured output must be a JSON object (e.g. a JSON schema)."}:{valid:!0}}catch(t){return{valid:!1,error:t instanceof Error?t.message:"Invalid JSON"}}}}}]);
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.