@e-llm-studio/instant-learning 1.3.0-alpha.241 → 1.3.0-alpha.243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/IL-OTJ/_components/hooks/useVariantEditSession.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/IL-OTJ/_components/hooks/useVariantEditSession.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/types/src/features/IL-OTJ/_components/hooks/useVariantEditSession.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),t=require("react"),i=function(n){return!!n&&/[a-z0-9À-]/i.test(n)},e=function(n){return n.filter(function(n){return i(n.text)}).map(function(n,t){return"".concat(t+1,") ").concat(n.text.trim())}).join(" ")},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),t=require("react"),i=function(n){return!!n&&/[a-z0-9À-]/i.test(n)},e=function(n){return n.filter(function(n){return i(n.text)}).map(function(n,t){return"".concat(t+1,") ").concat(n.text.trim())}).join(" ")},r=function(n){return n.filter(function(n){return i(n.text)}).map(function(n){return n.text.trim()}).join("\n")},o=function(n,t){var e=new Set(t.map(function(n){return n.id})),r=new Set(n.map(function(n){return n.id})),o=n.filter(function(n){return!e.has(n.id)});return{added:t.filter(function(n){return!r.has(n.id)&&i(n.text)}),removed:o,edited:t.filter(function(t){var i=n.find(function(n){return n.id===t.id});return!!i&&i.text.trim()!==t.text.trim()})}},a=function(n){return n.removed.length>0&&0===n.added.length&&0===n.edited.length?"remove":"update"},l=function(n,t){var i="I have updated the instruction prompt through RHS";if(0===n.length)return i;var e=n.filter(function(n){return"remove"===n.action}),r=n.filter(function(n){return"update"===n.action}),o=[];e.length>0&&o.push("remove ".concat(e.map(function(n){return"".concat(n.label," - ").concat(n.value)}).join(", "))),r.length>0&&o.push("update details ".concat(r.map(function(n){return"".concat(n.label," - ").concat(n.value)}).join(", ")));var a=o.join("; ");return t?"".concat(a,". Also, ").concat(i.toLowerCase()):a};exports.buildEditMessage=l,exports.conditionsToStoreText=r,exports.conditionsToText=e,exports.diffConditions=o,exports.hasMeaningfulText=i,exports.useVariantEditSession=function(u,d,s){var c=t.useState(null),f=c[0],p=c[1],v=t.useState(null),_=v[0],g=v[1],h=t.useRef(null==u?void 0:u.isAiStreaming);t.useEffect(function(){h.current&&!(null==u?void 0:u.isAiStreaming)&&_&&g(null),h.current=null==u?void 0:u.isAiStreaming},[null==u?void 0:u.isAiStreaming,_]);var m=function(){var n,t;p(null),null===(n=null==u?void 0:u.setActiveEditId)||void 0===n||n.call(u,null),null===(t=null==u?void 0:u.setPendingEditId)||void 0===t||t.call(u,null)};return{variantEdit:f,pendingVariantId:_,handleStartVariantEdit:function(n,t,i,e){var r,o,a,l="variant-".concat(t,"-").concat(i);if((null==u?void 0:u.activeEditId)&&u.activeEditId!==l)null===(r=null==u?void 0:u.setPendingEditId)||void 0===r||r.call(u,u.activeEditId);else{var s=d(n);p({id:l,tierKey:t,variantIndex:i,label:e,original:s,draft:d(n)}),null===(o=null==u?void 0:u.setActiveEditId)||void 0===o||o.call(u,l),null===(a=null==u?void 0:u.setPendingEditId)||void 0===a||a.call(u,null)}},handleCancelVariantEdit:m,patchVariantDraft:function(t){p(function(i){return i?n.__assign(n.__assign({},i),{draft:n.__assign(n.__assign({},i.draft),t)}):i})},editDraftCondition:function(t,i,e){p(function(r){var o;return r?n.__assign(n.__assign({},r),{draft:n.__assign(n.__assign({},r.draft),(o={},o[t]=r.draft[t].map(function(t){return t.id===i?n.__assign(n.__assign({},t),{text:e}):t}),o))}):r})},removeDraftCondition:function(t,i){p(function(e){var r;return e?n.__assign(n.__assign({},e),{draft:n.__assign(n.__assign({},e.draft),(r={},r[t]=e.draft[t].filter(function(n){return n.id!==i}),r))}):e})},addDraftCondition:function(t){p(function(i){var e;return i?n.__assign(n.__assign({},i),{draft:n.__assign(n.__assign({},i.draft),(e={},e[t]=n.__spreadArray(n.__spreadArray([],i.draft[t],!0),[{id:"draft-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),text:""}],!1),e))}):i})},handleSaveVariantEdit:function(){var n,t;if(f){var d=f.draft,c=f.original,v=f.id,_={},h=[];d.ruleDescription.trim()!==c.ruleDescription.trim()&&(h.push({action:"update",label:"Description",value:d.ruleDescription.trim()||"None"}),_.ruleDescription=d.ruleDescription);var x=d.instructionPrompt.trim()!==c.instructionPrompt.trim();x&&(_.instructionPrompt=d.instructionPrompt);var A=o(c.whenToApplyConditions,d.whenToApplyConditions),T=o(c.whenNotToApplyConditions,d.whenNotToApplyConditions),y=e(d.whenToApplyConditions),E=e(d.whenNotToApplyConditions),C=y!==e(c.whenToApplyConditions),S=E!==e(c.whenNotToApplyConditions),w=function(n){return n.filter(function(n){return i(n.text)}).map(function(n){return n.text.trim()}).join(", ")};if(C){var I=a(A);h.push({action:I,label:"When to Apply",value:"remove"===I?w(A.removed):y||"None"}),_.whenToApplyText=r(d.whenToApplyConditions)}if(S){I=a(T);h.push({action:I,label:"When Not to Apply",value:"remove"===I?w(T.removed):E||"None"}),_.whenNotToApplyText=r(d.whenNotToApplyConditions)}if(0!==h.length||x){if(Object.keys(_).length>0&&(null==s||s(_,f)),null==u?void 0:u.setSendMessageInChat){var D="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));u.setSendMessageInChat("__SKELETON__:".concat(D,":").concat(l(h,x))),g(v)}p(null),null===(n=null==u?void 0:u.setActiveEditId)||void 0===n||n.call(u,null),null===(t=null==u?void 0:u.setPendingEditId)||void 0===t||t.call(u,null)}else m()}}}};
|
|
2
2
|
//# sourceMappingURL=useVariantEditSession.js.map
|