import{aa as m,ab as p}from"./_applist-tangy-colts-beg-36.js";import{_ as a}from"./main-tangy-colts-beg.js";import{s as d}from"./machine.-tangy-colts-beg-869.js";import{a as s}from"./machineh-tangy-colts-beg-630.js";import{h as l,b as c,c as E}from"./openaico-tangy-colts-beg-990.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,e){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,e),e)}};const O=m(({helpers:o})=>({states:{components:[E(o),{componentName:o.componentName.select,id:"model-id",label:a("Select Model"),onChange:"SET_MODEL",onRefetch:"REFETCH_MODEL_LIST",optionFilterProp:"label",options:[],path:"model",placeholder:a("Select a Model"),render:"IF_CONNECTION_SELECTED",required:!0,showSearch:!0,value:void 0},{componentName:o.componentName.mixInput,helperText:a("Short description of what type of data to extract from the text."),id:"prompt",label:a("Prompt"),onChange:"SET_PROMPT",path:"prompt",render:"IF_CONNECTION_SELECTED",required:!0,value:[]},{componentName:o.componentName.mixInput,helperText:a("Text in any format to extract the structured data from."),id:"content",label:a("Text to Parse"),onChange:"SET_CONTENT",path:"content",render:"IF_CONNECTION_SELECTED",required:!0,value:[]},{componentName:o.componentName.input,helperText:a('NOTE: kindly use this format for response. { "type": "json_schema", "json_schema": {{Your_JSON_Schema}} }'),id:"response",invalidMessage:"",label:a("Response"),onChange:"SET_RESPONSE",path:"response_format",render:"IF_CONNECTION_SELECTED",required:!0,status:"",type:"text",value:""}]},actions:{SET_CONNECTION:async({$:e,e:t})=>{e.setThisComponent(r=>{r.value=t}),e.setDb(r=>{r.connectionId=t}),await s(e)},IF_CONNECTION_SELECTED:({$:e})=>{var t;return p((t=e.getComponent("connection-id"))==null?void 0:t.value)},REFETCH_MODEL_LIST:async({$:e})=>{await s(e)},SET_MODEL:c("model"),SET_PROMPT:c("prompt"),SET_CONTENT:c("content"),SET_RESPONSE:async({$:e,e:t})=>{const r=t.target.value;e.setThisComponent(n=>{n.value=r}),e.setDb(n=>{n.response=r});try{JSON.parse(r),e.setThisComponent(n=>{e.util.isInputComponent(n)&&(n.status=void 0)})}catch(n){console.error(n),e.setThisComponent(i=>{e.util.isInputComponent(i)&&(i.invalidMessage="Invalid Format",i.status="error")})}},CONNECTION_ADD_CHANGE:l,ON_MACHINE_LOAD:async({$:e})=>{var t;d(e,[{db:"connectionId",id:"connection-id"},{db:"model",id:"model-id"},{db:"prompt",id:"prompt"},{db:"content",id:"content"},{db:"response",id:"response"}]),(t=e.db)!=null&&t.connectionId&&await s(e)}}}));export{O as default};
