import{b as p,i as c}from"./useflows-BpG3C9m1.js";import{e as o}from"./main-few-lands-burn.js";import{s as d}from"./machine.-BRuqPpdF.js";import{a as s}from"./machineh-DnUoNsH-.js";import{h as E,a as m,c as l}from"./openaico-BZSnTkIZ.js";import"./mutative-C6xjlr6O.js";import"./lodash-YpNkAOPN.js";const S=p(({helpers:a})=>({states:{components:[l(a),{componentName:a.componentName.select,id:"model-id",label:o("Select Model"),onChange:"SET_MODEL",onRefetch:"REFETCH_MODEL_LIST",optionFilterProp:"label",options:[],path:"model",placeholder:o("Select a Model"),render:"IF_CONNECTION_SELECTED",required:!0,showSearch:!0,value:void 0},{componentName:a.componentName.mixInput,helperText:o("Short description of what type of data to extract from the text."),id:"prompt",label:o("Prompt"),onChange:"SET_PROMPT",path:"prompt",render:"IF_CONNECTION_SELECTED",required:!0,value:[]},{componentName:a.componentName.mixInput,helperText:o("Text in any format to extract the structured data from."),id:"content",label:o("Text to Parse"),onChange:"SET_CONTENT",path:"content",render:"IF_CONNECTION_SELECTED",required:!0,value:[]},{componentName:a.componentName.input,helperText:o('NOTE: kindly use this format for response. { "type": "json_schema", "json_schema": {{Your_JSON_Schema}} }'),id:"response",invalidMessage:"",label:o("Response"),onChange:"SET_RESPONSE",path:"response_format",render:"IF_CONNECTION_SELECTED",required:!0,status:"",type:"text",value:""}]},actions:{SET_CONNECTION:async({$:e,e:r})=>{e.setThisComponent(n=>{n.value=r}),e.setDb(n=>{n.connectionId=r}),await s(e)},IF_CONNECTION_SELECTED:({$:e})=>c(e.getComponent("connection-id")?.value),REFETCH_MODEL_LIST:async({$:e})=>{await s(e)},SET_MODEL:m("model"),SET_PROMPT:m("prompt"),SET_CONTENT:m("content"),SET_RESPONSE:async({$:e,e:r})=>{const n=r.target.value;e.setThisComponent(t=>{t.value=n}),e.setDb(t=>{t.response=n});try{JSON.parse(n),e.setThisComponent(t=>{e.util.isInputComponent(t)&&(t.status=void 0)})}catch(t){console.error(t),e.setThisComponent(i=>{e.util.isInputComponent(i)&&(i.invalidMessage="Invalid Format",i.status="error")})}},CONNECTION_ADD_CHANGE:E,ON_MACHINE_LOAD:async({$:e})=>{d(e,[{db:"connectionId",id:"connection-id"},{db:"model",id:"model-id"},{db:"prompt",id:"prompt"},{db:"content",id:"content"},{db:"response",id:"response"}]),e.db?.connectionId&&await s(e)}}}));export{S as default};
