@e-llm-studio/requirement-ai 0.0.288 → 0.0.290
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>e.replace(/<onDemandCitation\
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>e.replace(/<onDemandCitation\b([^>]*)>(.*?)<\/onDemandCitation>/gs,(e,t,n)=>{const r=e=>{var n;return null===(n=t.match(new RegExp(`${e}=(?:"|\\\\")([^"]*)(?:"|\\\\")`)))||void 0===n?void 0:n[1]},o=r("href"),i=r("source"),s=r("type"),c=r("citationNo");return`<a href="${o||(s&&c?`${s}$${c}?type=on_demand`:"")}" source="${null!=i?i:""}">${n||"Source"}</a>`});function t(e,t){if(!e)return e;let n="",r=0;for(;;){const o=e.indexOf("<gpt_citation_here ",r);if(-1===o){n+=e.slice(r);break}n+=e.slice(r,o);const i=e.indexOf(">",o);if(-1===i){n+=e.slice(o);break}const s=e.slice(o,i+1),c=s.indexOf("id=");let a="";if(-1!==c){let e=c+3;for("\\"===s[e]&&e++,'"'!==s[e]&&"'"!==s[e]||e++;e<s.length&&/\d/.test(s[e]);)a+=s[e++]}if(a){n+=`<a href="gpt_citation$${`${t}<GPT_CITATION_ID>${a}`}">Source</a>`}r=i+1}return n}function n(e,t){const n=t=>{const n=new RegExp(`<${t}>([\\s\\S]*?)<\\/${t}>`,"gi"),r=[];let o;for(;null!==(o=n.exec(e));)r.push(o[1].trim());return r},r=n("domain"),o=n("paraphrase");return{citation_number:t,customMetadata:{type:"gpt_citation",data_sources:n("data_sources"),training_data_title:r,paraphrase:o}}}exports.extractBlockStreams=e=>{const t=[];try{const n="<BLOCK_STREAM_START>",r="<BLOCK_STREAM_END>";let o=0;for(;;){const i=e.indexOf(n,o);if(-1===i)break;const s=e.indexOf(r,i+n.length);if(-1===s)break;const c=e.slice(i+n.length,s).trim();t.push(JSON.parse(c)),o=s+r.length}}catch(e){console.error("Error in extracting blocks from stream",e)}finally{return t}},exports.extractDescription=function(e){try{const t=/<h2>\s*(?:<b>)?Description(?:<\/b>)?\s*<\/h2>\s*([\s\S]*?)(?=\s*<h2>|$)/i,n=e.match(t);if(n)return n[1].trim()}catch(e){}return null},exports.parseGptCitation=n,exports.processAIReasoningFromBlocks=function(r,o,i,s){const c=[];let a="";const l=[];let u="";console.log("RAW INPUT",JSON.stringify(r),JSON.stringify(s));try{const d=r=>r.replace(/<a\s+(?:(table="true")\s+)?href=(\\"|")ai_reasoning\$(\d+)(\?[^\\"]*)?(\\"|")>([\s\S]*?)<\/a>/g,(r,s,a,u,d,p,f)=>{var h,g,_,$,m;const b=`${u}<BLOCK_NUMBER>${o}<STORY_NUMBER>${i}`,x=!!d&&d.includes("type=on_demand"),v=function(e){const t=new Map,n="<gpt_citation ",r="</gpt_citation>";let o=0;for(;;){const i=e.indexOf(n,o);if(-1===i)break;const s=e.indexOf(">",i);if(-1===s)break;const c=e.indexOf(r,s);if(-1===c)break;const a=e.slice(i,c+r.length),l=e.slice(i,s+1),u=l.indexOf("id=");if(-1!==u){let e=u+3;"\\"===l[e]&&e++,'"'!==l[e]&&"'"!==l[e]||e++;let n="";for(;e<l.length&&/\d/.test(l[e]);)n+=l[e++];n&&t.set(n,a)}o=c+r.length}return t}(f);console.log("RAW INPUT",v);const S=f.match(/<reason(?:\s+source="([^"]*)")?>([\s\S]*?)<\/reason>/),O=f.match(/<gap(?:\s+source="([^"]*)")?>([\s\S]*?)<\/gap>/),T=f.match(/<relevance_score>([\s\S]*?)<\/relevance_score>/);let y=(null===(h=null==S?void 0:S[2])||void 0===h?void 0:h.trim())||"",R=(null===(g=null==O?void 0:O[2])||void 0===g?void 0:g.trim())||"";y=e(y),R=e(R),y=t(y,b),R=t(R,b),v.forEach((e,t)=>{const r=`${b}<GPT_CITATION_ID>${t}`;l.push(n(e,r))}),c.push({id:b,reason:y,reasonSource:(null===(_=null==S?void 0:S[1])||void 0===_?void 0:_.trim())||"",gap:R,gapSource:(null===($=null==O?void 0:O[1])||void 0===$?void 0:$.trim())||"",relevance_score:Number(null===(m=null==T?void 0:T[1])||void 0===m?void 0:m.trim())||0,on_demand:x});return`<a ${s?'table="true"':""} href=${a}ai_reasoning$${b}${d||""}${p}>Source</a>`});a=d(r),s&&(u=d(s))}catch(e){console.error("Error in extracting AI Reasoning from this block:",r)}finally{return{outputText:a,reasonings:c,gpt_citation:l,processedDescription:u}}},exports.processUserStoryValue=(e,t,n)=>{let r=e.includes("<h1><b>Title</b></h1>\n\n")?e:n?`<h1><b>Title</b></h1>\n\n${n} \n${e}`:e;return r=r.includes("<h1><b>Requirement Type</b></h1>\n\n")?r:t?`<h1><b>Requirement Type</b></h1>\n\n${t} \n${r}`:r,r},exports.replaceGptCitation=t;
|
|
2
2
|
//# sourceMappingURL=proccess-stream.utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=e=>{const n=[];try{const t="<BLOCK_STREAM_START>",
|
|
1
|
+
const e=e=>{const n=[];try{const t="<BLOCK_STREAM_START>",r="<BLOCK_STREAM_END>";let o=0;for(;;){const i=e.indexOf(t,o);if(-1===i)break;const s=e.indexOf(r,i+t.length);if(-1===s)break;const c=e.slice(i+t.length,s).trim();n.push(JSON.parse(c)),o=s+r.length}}catch(e){console.error("Error in extracting blocks from stream",e)}finally{return n}},n=e=>e.replace(/<onDemandCitation\b([^>]*)>(.*?)<\/onDemandCitation>/gs,(e,n,t)=>{const r=e=>{var t;return null===(t=n.match(new RegExp(`${e}=(?:"|\\\\")([^"]*)(?:"|\\\\")`)))||void 0===t?void 0:t[1]},o=r("href"),i=r("source"),s=r("type"),c=r("citationNo");return`<a href="${o||(s&&c?`${s}$${c}?type=on_demand`:"")}" source="${null!=i?i:""}">${t||"Source"}</a>`});function t(e,t,i,s){const c=[];let a="";const l=[];let u="";console.log("RAW INPUT",JSON.stringify(e),JSON.stringify(s));try{const d=e=>e.replace(/<a\s+(?:(table="true")\s+)?href=(\\"|")ai_reasoning\$(\d+)(\?[^\\"]*)?(\\"|")>([\s\S]*?)<\/a>/g,(e,s,a,u,d,f,h)=>{var p,g,$,_,m;const b=`${u}<BLOCK_NUMBER>${t}<STORY_NUMBER>${i}`,v=!!d&&d.includes("type=on_demand"),O=function(e){const n=new Map,t="<gpt_citation ",r="</gpt_citation>";let o=0;for(;;){const i=e.indexOf(t,o);if(-1===i)break;const s=e.indexOf(">",i);if(-1===s)break;const c=e.indexOf(r,s);if(-1===c)break;const a=e.slice(i,c+r.length),l=e.slice(i,s+1),u=l.indexOf("id=");if(-1!==u){let e=u+3;"\\"===l[e]&&e++,'"'!==l[e]&&"'"!==l[e]||e++;let t="";for(;e<l.length&&/\d/.test(l[e]);)t+=l[e++];t&&n.set(t,a)}o=c+r.length}return n}(h);console.log("RAW INPUT",O);const S=h.match(/<reason(?:\s+source="([^"]*)")?>([\s\S]*?)<\/reason>/),T=h.match(/<gap(?:\s+source="([^"]*)")?>([\s\S]*?)<\/gap>/),x=h.match(/<relevance_score>([\s\S]*?)<\/relevance_score>/);let y=(null===(p=null==S?void 0:S[2])||void 0===p?void 0:p.trim())||"",R=(null===(g=null==T?void 0:T[2])||void 0===g?void 0:g.trim())||"";y=n(y),R=n(R),y=r(y,b),R=r(R,b),O.forEach((e,n)=>{const t=`${b}<GPT_CITATION_ID>${n}`;l.push(o(e,t))}),c.push({id:b,reason:y,reasonSource:(null===($=null==S?void 0:S[1])||void 0===$?void 0:$.trim())||"",gap:R,gapSource:(null===(_=null==T?void 0:T[1])||void 0===_?void 0:_.trim())||"",relevance_score:Number(null===(m=null==x?void 0:x[1])||void 0===m?void 0:m.trim())||0,on_demand:v});return`<a ${s?'table="true"':""} href=${a}ai_reasoning$${b}${d||""}${f}>Source</a>`});a=d(e),s&&(u=d(s))}catch(n){console.error("Error in extracting AI Reasoning from this block:",e)}finally{return{outputText:a,reasonings:c,gpt_citation:l,processedDescription:u}}}function r(e,n){if(!e)return e;let t="",r=0;for(;;){const o=e.indexOf("<gpt_citation_here ",r);if(-1===o){t+=e.slice(r);break}t+=e.slice(r,o);const i=e.indexOf(">",o);if(-1===i){t+=e.slice(o);break}const s=e.slice(o,i+1),c=s.indexOf("id=");let a="";if(-1!==c){let e=c+3;for("\\"===s[e]&&e++,'"'!==s[e]&&"'"!==s[e]||e++;e<s.length&&/\d/.test(s[e]);)a+=s[e++]}if(a){t+=`<a href="gpt_citation$${`${n}<GPT_CITATION_ID>${a}`}">Source</a>`}r=i+1}return t}function o(e,n){const t=n=>{const t=new RegExp(`<${n}>([\\s\\S]*?)<\\/${n}>`,"gi"),r=[];let o;for(;null!==(o=t.exec(e));)r.push(o[1].trim());return r},r=t("domain"),o=t("paraphrase");return{citation_number:n,customMetadata:{type:"gpt_citation",data_sources:t("data_sources"),training_data_title:r,paraphrase:o}}}const i=(e,n,t)=>{let r=e.includes("<h1><b>Title</b></h1>\n\n")?e:t?`<h1><b>Title</b></h1>\n\n${t} \n${e}`:e;return r=r.includes("<h1><b>Requirement Type</b></h1>\n\n")?r:n?`<h1><b>Requirement Type</b></h1>\n\n${n} \n${r}`:r,r};function s(e){try{const n=/<h2>\s*(?:<b>)?Description(?:<\/b>)?\s*<\/h2>\s*([\s\S]*?)(?=\s*<h2>|$)/i,t=e.match(n);if(t)return t[1].trim()}catch(e){}return null}export{e as extractBlockStreams,s as extractDescription,o as parseGptCitation,t as processAIReasoningFromBlocks,i as processUserStoryValue,r as replaceGptCitation};
|
|
2
2
|
//# sourceMappingURL=proccess-stream.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proccess-stream.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/features/RequirementAI/utils/proccess-stream.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,mBAAmB,UAAW,MAAM,sBA4BhD,CAAA;
|
|
1
|
+
{"version":3,"file":"proccess-stream.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/features/RequirementAI/utils/proccess-stream.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,mBAAmB,UAAW,MAAM,sBA4BhD,CAAA;AA0BD,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACrB;IACC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;CAChC,CA8FA;AAwCD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAoC3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAkCvE;AAED,eAAO,MAAM,qBAAqB,UAAW,MAAM,iBAAiB,MAAM,SAAS,MAAM,WAIxF,CAAA;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc9D"}
|