@e-llm-studio/requirement-ai 0.0.287 → 0.0.289

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});var e=require("react"),t=require("../utils/proccess-stream.utils.js");exports.useStreamContentHandler=function({setUserStory:i,setAiReasoning:o,setUserStoryCitations:n,onStreamingCompleted:r,isGraphQLCallInProgress:s,knowledgeBase:a,projectAnalyserSummary:l,dataSourceFiles:u,aiReasoning:c,setRedisValue:d,fetchCitationByBlock:p}){const[_,m]=e.useState({finalGap:"",finalRisk:"",status:"in-progress"}),f=e.useRef(new Set),g=e.useRef(new Set),b=e.useRef(null),v=e.useRef(null),h=e.useRef({gap_items_prompt:"",risk_items_prompt:""}),k=e.useRef(new Set);return e.useEffect(()=>{"complete"!==_.status||s||(r(_.finalGap,_.finalRisk),f.current.clear(),g.current.clear(),b.current=null,v.current=null,h.current={gap_items_prompt:"",risk_items_prompt:""},k.current.clear(),m({finalGap:"",finalRisk:"",status:"in-progress"}))},[_,s]),{processStreamContent:function(e,r,s){try{const _=JSON.stringify(e);if(v.current===_)return;v.current=_;let y=[],R=[];e=e.map(e=>{var i;const s=`${(e={...e,subBlockNumber:null!==(i=e.subBlockNumber)&&void 0!==i?i:"1"}).storyNumber}-${e.blockNumber}-${e.subBlockNumber}`;if(k.current.has(s))return null;k.current.add(s);let{outputText:a,reasonings:l,gpt_citation:u,processedDescription:c}=t.processAIReasoningFromBlocks(e.value,e.blockNumber,e.storyNumber,e.description);n(e=>{var t;return u.length>0&&((null==e?void 0:e.gpt_citations)||(e.gpt_citations=[]),null===(t=e.gpt_citations)||void 0===t||t.push(...u)),{...e}}),y.push(...l),R.push([...l]);const d=l.filter(e=>e.on_demand).flatMap(e=>[...e.reason.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g),...e.gap.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g)].map(e=>{const[t,i]=e[1].split("$");return"book_citation_doc"!==t&&"book_citation_pdf"!==t&&"document_citation"!==t?null:{citation_number:i,customMetadata:{type:"document_citation"===t?"book_citation_pdf":t,file_name:"",fileType:"",gcs_upload_url:""}}}).filter(Boolean));d.length&&n(e=>{var t;return{...e,file_citations:[...null!==(t=e.file_citations)&&void 0!==t?t:[],...d]}});let _=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}<SUB_BLOCK>${e.subBlockNumber}`;return f.current.has(_)||(!async function(e,t,i){var r,s;let a="",l="";try{const u=await p(e,i,t);o(e=>{var t;const i=[...e];return null===(t=u.response.ai_reasonings)||void 0===t||t.forEach(e=>{const t=i.findIndex(t=>t.id===e.id);-1!==t&&e.gap.length>0&&e.reason.length>0&&(i[t]={...e})}),i}),a=(null===(r=u.response)||void 0===r?void 0:r.gap_items_prompt)||"",l=(null===(s=u.response)||void 0===s?void 0:s.risk_items_prompt)||"",(a||l)&&(h.current={gap_items_prompt:a,risk_items_prompt:l}),n(e=>{var t,i,o,n,r,s,a,l,c,d,p,_,m,f;return{...e,appmod_citations:[...null!==(t=e.appmod_citations)&&void 0!==t?t:[],...null!==(i=u.response.appmod_citations)&&void 0!==i?i:[]],audio_citations:[...null!==(o=e.audio_citations)&&void 0!==o?o:[],...null!==(n=u.response.audio_citations)&&void 0!==n?n:[]],file_citations:[...null!==(r=e.file_citations)&&void 0!==r?r:[],...null!==(s=u.response.file_citations)&&void 0!==s?s:[]],image_citations:[...null!==(a=e.image_citations)&&void 0!==a?a:[],...null!==(l=u.response.image_citations)&&void 0!==l?l:[]],rca_citations:[...null!==(c=e.rca_citations)&&void 0!==c?c:[],...null!==(d=u.response.rca_citations)&&void 0!==d?d:[]],web_citations:[...null!==(p=e.web_citations)&&void 0!==p?p:[],...null!==(_=u.response.web_citations)&&void 0!==_?_:[]],readfile_citations:[...null!==(m=e.readfile_citations)&&void 0!==m?m:[],...null!==(f=u.response.readfile_citations)&&void 0!==f?f:[]]}})}catch(t){console.error("[liblogs] processCitationsByBlock error — story:%s block:%s",e.storyNumber,e.blockNumber,t)}finally{let t=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}`;if(g.current.add(t),g.current.size===f.current.size){const e=a||h.current.gap_items_prompt,t=l||h.current.risk_items_prompt;m({finalGap:e,finalRisk:t,status:"complete"})}}}({...e,value:a,description:c},l,r),f.current.add(_)),{...e,value:a,description:c}}).filter(Boolean),y.forEach(e=>{o(t=>(t.find(t=>t.id===e.id)||t.push(e),[...t]))}),e.length>0&&e.map(({title:e,section:t,value:o,storyNumber:n,description:r,blockNumber:p,big_enough:_,big_enough_decision_factors:m,gapValue:f,confidenceScore:g,metadata:v},h)=>{i(i=>{var k,y,N,S,B,$,C,O;const w=i.findIndex(e=>e.storyNumber===n);if("intro"===t)-1===w?i.push({artifactId:`STORY-${n}-${p}`,title:e,value:o,description:r,storyNumber:n,sub_features:[],section:t,blockNumber:p,aiReasoning:R[h],big_enough:_,big_enough_decision_factors:m,gapValue:f,confidenceScore:g,metadata:v}):(i[w].value+=o,i[w].aiReasoning=i[w].aiReasoning||[],null===(y=null===(k=i[w])||void 0===k?void 0:k.aiReasoning)||void 0===y||y.push(...R[h]),i[w].big_enough=_,i[w].big_enough_decision_factors=m,i[w].gapValue=f,i[w].confidenceScore=g,i[w].metadata=v);else{i[w].sub_features||(i[w].sub_features=[]);const r=(null===(S=null===(N=i[w])||void 0===N?void 0:N.sub_features)||void 0===S?void 0:S.findIndex(e=>e.blockNumber===p))||-1;if(-1===r)null===($=null===(B=i[w])||void 0===B?void 0:B.sub_features)||void 0===$||$.push({artifactId:`STORY-${n}-${p}`,title:e,value:o,storyNumber:n,blockNumber:p,section:t,aiReasoning:R[h],big_enough:_,big_enough_decision_factors:m,gapValue:f,confidenceScore:g,metadata:v});else{let e=null===(O=null===(C=null==i?void 0:i[w])||void 0===C?void 0:C.sub_features)||void 0===O?void 0:O[r];e.value=(e.value||"")+o,e.aiReasoning=e.aiReasoning||[],e.aiReasoning.push(...R[h]),e.big_enough=_,e.big_enough_decision_factors=m,e.gapValue=f,e.confidenceScore=g,e.metadata=v}}const E=JSON.stringify(i);return b.current!==E&&(d({key:`streaming-redis-key-${s}`,value:{mmvf_list:i,knowledgeBase:a,projectAnalyserSummary:l,dataSources_files:u,ai_reasonings:c}}),b.current=E),[...i]})})}catch(e){console.error("Error in processing Stream Content",e)}}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/proccess-stream.utils.js");exports.useStreamContentHandler=function({setUserStory:i,setAiReasoning:n,setUserStoryCitations:o,onStreamingCompleted:r,isGraphQLCallInProgress:s,knowledgeBase:a,projectAnalyserSummary:l,dataSourceFiles:u,aiReasoning:c,setRedisValue:d,fetchCitationByBlock:p,isOnDemandCitation:_}){const[m,f]=e.useState({finalGap:"",finalRisk:"",status:"in-progress"}),g=e.useRef(new Set),b=e.useRef(new Set),v=e.useRef(null),h=e.useRef(null),k=e.useRef({gap_items_prompt:"",risk_items_prompt:""}),y=e.useRef(new Set);return e.useEffect(()=>{"complete"!==m.status||s||(r(m.finalGap,m.finalRisk),g.current.clear(),b.current.clear(),v.current=null,h.current=null,k.current={gap_items_prompt:"",risk_items_prompt:""},y.current.clear(),f({finalGap:"",finalRisk:"",status:"in-progress"}))},[m,s]),{processStreamContent:function(e,s,m,R){try{const N=JSON.stringify(e);if(h.current===N)return;h.current=N;let S=[],B=[];e=e.map(e=>{var i;const r=`${(e={...e,subBlockNumber:null!==(i=e.subBlockNumber)&&void 0!==i?i:"1"}).storyNumber}-${e.blockNumber}-${e.subBlockNumber}`;if(y.current.has(r))return null;y.current.add(r);let{outputText:a,reasonings:l,gpt_citation:u,processedDescription:c}=t.processAIReasoningFromBlocks(e.value,e.blockNumber,e.storyNumber,e.description);o(e=>{var t;return u.length>0&&((null==e?void 0:e.gpt_citations)||(e.gpt_citations=[]),null===(t=e.gpt_citations)||void 0===t||t.push(...u)),{...e}}),S.push(...l),B.push([...l]);const d=l.filter(e=>e.on_demand).flatMap(e=>[...e.reason.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g),...e.gap.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g)].map(e=>{const[t,i]=e[1].split("$");return"book_citation_doc"!==t&&"book_citation_pdf"!==t&&"document_citation"!==t?null:{citation_number:i,customMetadata:{type:"document_citation"===t?"book_citation_pdf":t,file_name:"",fileType:"",gcs_upload_url:""}}}).filter(Boolean));d.length&&o(e=>{var t;return{...e,file_citations:[...null!==(t=e.file_citations)&&void 0!==t?t:[],...d]}});let _=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}<SUB_BLOCK>${e.subBlockNumber}`;return g.current.has(_)||(!async function(e,t,i){var r,s;let a="",l="";try{const u=await p(e,i,t);n(e=>{var t;const i=[...e];return null===(t=u.response.ai_reasonings)||void 0===t||t.forEach(e=>{const t=i.findIndex(t=>t.id===e.id);-1!==t&&e.gap.length>0&&e.reason.length>0&&(i[t]={...e})}),i}),a=(null===(r=u.response)||void 0===r?void 0:r.gap_items_prompt)||"",l=(null===(s=u.response)||void 0===s?void 0:s.risk_items_prompt)||"",(a||l)&&(k.current={gap_items_prompt:a,risk_items_prompt:l}),o(e=>{var t,i,n,o,r,s,a,l,c,d,p,_,m,f;return{...e,appmod_citations:[...null!==(t=e.appmod_citations)&&void 0!==t?t:[],...null!==(i=u.response.appmod_citations)&&void 0!==i?i:[]],audio_citations:[...null!==(n=e.audio_citations)&&void 0!==n?n:[],...null!==(o=u.response.audio_citations)&&void 0!==o?o:[]],file_citations:[...null!==(r=e.file_citations)&&void 0!==r?r:[],...null!==(s=u.response.file_citations)&&void 0!==s?s:[]],image_citations:[...null!==(a=e.image_citations)&&void 0!==a?a:[],...null!==(l=u.response.image_citations)&&void 0!==l?l:[]],rca_citations:[...null!==(c=e.rca_citations)&&void 0!==c?c:[],...null!==(d=u.response.rca_citations)&&void 0!==d?d:[]],web_citations:[...null!==(p=e.web_citations)&&void 0!==p?p:[],...null!==(_=u.response.web_citations)&&void 0!==_?_:[]],readfile_citations:[...null!==(m=e.readfile_citations)&&void 0!==m?m:[],...null!==(f=u.response.readfile_citations)&&void 0!==f?f:[]]}})}catch(t){console.error("[liblogs] processCitationsByBlock error — story:%s block:%s",e.storyNumber,e.blockNumber,t)}finally{let t=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}`;if(b.current.add(t),b.current.size===g.current.size){const e=a||k.current.gap_items_prompt,t=l||k.current.risk_items_prompt;f({finalGap:e,finalRisk:t,status:"complete"})}}}({...e,value:a,description:c},l,s),g.current.add(_)),{...e,value:a,description:c}}).filter(Boolean),S.forEach(e=>{n(t=>(t.find(t=>t.id===e.id)||t.push(e),[...t]))}),e.length>0&&e.map(({title:e,section:t,value:n,storyNumber:o,description:r,blockNumber:s,big_enough:p,big_enough_decision_factors:_,gapValue:f,confidenceScore:g,metadata:b},h)=>{i(i=>{var k,y,R,N,S,$,C,O;const w=i.findIndex(e=>e.storyNumber===o);if("intro"===t)-1===w?i.push({artifactId:`STORY-${o}-${s}`,title:e,value:n,description:r,storyNumber:o,sub_features:[],section:t,blockNumber:s,aiReasoning:B[h],big_enough:p,big_enough_decision_factors:_,gapValue:f,confidenceScore:g,metadata:b}):(i[w].value+=n,i[w].aiReasoning=i[w].aiReasoning||[],null===(y=null===(k=i[w])||void 0===k?void 0:k.aiReasoning)||void 0===y||y.push(...B[h]),i[w].big_enough=p,i[w].big_enough_decision_factors=_,i[w].gapValue=f,i[w].confidenceScore=g,i[w].metadata=b);else{i[w].sub_features||(i[w].sub_features=[]);const r=(null===(N=null===(R=i[w])||void 0===R?void 0:R.sub_features)||void 0===N?void 0:N.findIndex(e=>e.blockNumber===s))||-1;if(-1===r)null===($=null===(S=i[w])||void 0===S?void 0:S.sub_features)||void 0===$||$.push({artifactId:`STORY-${o}-${s}`,title:e,value:n,storyNumber:o,blockNumber:s,section:t,aiReasoning:B[h],big_enough:p,big_enough_decision_factors:_,gapValue:f,confidenceScore:g,metadata:b});else{let e=null===(O=null===(C=null==i?void 0:i[w])||void 0===C?void 0:C.sub_features)||void 0===O?void 0:O[r];e.value=(e.value||"")+n,e.aiReasoning=e.aiReasoning||[],e.aiReasoning.push(...B[h]),e.big_enough=p,e.big_enough_decision_factors=_,e.gapValue=f,e.confidenceScore=g,e.metadata=b}}const E=JSON.stringify(i);return v.current!==E&&(d({key:`streaming-redis-key-${m}`,value:{mmvf_list:i,knowledgeBase:a,projectAnalyserSummary:l,dataSources_files:u,ai_reasonings:c}}),v.current=E),[...i]})}),R&&_&&r()}catch(e){console.error("Error in processing Stream Content",e)}}}};
2
2
  //# sourceMappingURL=useStreamContentHandler.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>e.replace(/<onDemandCitation\s+type=(?:\\"|")([^"]+)(?:\\"|")\s+citationNo=(?:\\"|")(\d+)(?:\\"|")\s*(?:\/>|><\/onDemandCitation>)/g,(e,t,n)=>`<a href="${t}$${n}?type=on_demand">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===(m=null==O?void 0:O[1])||void 0===m?void 0:m.trim())||"",relevance_score:Number(null===($=null==T?void 0:T[1])||void 0===$?void 0:$.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;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>e.replace(/<onDemandCitation\s+href=(?:\\"|")([^"]+)(?:\\"|")\s+source=(?:\\"|")([^"]+)(?:\\"|")\s+type=(?:\\"|")([^"]+)(?:\\"|")\s+citationNo=(?:\\"|")(\d+)(?:\\"|")\s*(?:\/>|><\/onDemandCitation>)/g,(e,t,n,r,o)=>`<a href="${t||`${r}$${o}?type=on_demand`}" source="${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===(m=null==O?void 0:O[1])||void 0===m?void 0:m.trim())||"",relevance_score:Number(null===($=null==T?void 0:T[1])||void 0===$?void 0:$.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
- import{useState as e,useRef as i,useEffect as t}from"react";import{processAIReasoningFromBlocks as o}from"../utils/proccess-stream.utils.js";function n({setUserStory:n,setAiReasoning:r,setUserStoryCitations:s,onStreamingCompleted:a,isGraphQLCallInProgress:l,knowledgeBase:u,projectAnalyserSummary:c,dataSourceFiles:d,aiReasoning:p,setRedisValue:_,fetchCitationByBlock:m}){const[g,f]=e({finalGap:"",finalRisk:"",status:"in-progress"}),b=i(new Set),v=i(new Set),h=i(null),k=i(null),y=i({gap_items_prompt:"",risk_items_prompt:""}),N=i(new Set);return t(()=>{"complete"!==g.status||l||(a(g.finalGap,g.finalRisk),b.current.clear(),v.current.clear(),h.current=null,k.current=null,y.current={gap_items_prompt:"",risk_items_prompt:""},N.current.clear(),f({finalGap:"",finalRisk:"",status:"in-progress"}))},[g,l]),{processStreamContent:function(e,i,t){try{const a=JSON.stringify(e);if(k.current===a)return;k.current=a;let l=[],g=[];e=e.map(e=>{var t;const n=`${(e={...e,subBlockNumber:null!==(t=e.subBlockNumber)&&void 0!==t?t:"1"}).storyNumber}-${e.blockNumber}-${e.subBlockNumber}`;if(N.current.has(n))return null;N.current.add(n);let{outputText:a,reasonings:u,gpt_citation:c,processedDescription:d}=o(e.value,e.blockNumber,e.storyNumber,e.description);s(e=>{var i;return c.length>0&&((null==e?void 0:e.gpt_citations)||(e.gpt_citations=[]),null===(i=e.gpt_citations)||void 0===i||i.push(...c)),{...e}}),l.push(...u),g.push([...u]);const p=u.filter(e=>e.on_demand).flatMap(e=>[...e.reason.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g),...e.gap.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g)].map(e=>{const[i,t]=e[1].split("$");return"book_citation_doc"!==i&&"book_citation_pdf"!==i&&"document_citation"!==i?null:{citation_number:t,customMetadata:{type:"document_citation"===i?"book_citation_pdf":i,file_name:"",fileType:"",gcs_upload_url:""}}}).filter(Boolean));p.length&&s(e=>{var i;return{...e,file_citations:[...null!==(i=e.file_citations)&&void 0!==i?i:[],...p]}});let _=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}<SUB_BLOCK>${e.subBlockNumber}`;return b.current.has(_)||(!async function(e,i,t){var o,n;let a="",l="";try{const u=await m(e,t,i);r(e=>{var i;const t=[...e];return null===(i=u.response.ai_reasonings)||void 0===i||i.forEach(e=>{const i=t.findIndex(i=>i.id===e.id);-1!==i&&e.gap.length>0&&e.reason.length>0&&(t[i]={...e})}),t}),a=(null===(o=u.response)||void 0===o?void 0:o.gap_items_prompt)||"",l=(null===(n=u.response)||void 0===n?void 0:n.risk_items_prompt)||"",(a||l)&&(y.current={gap_items_prompt:a,risk_items_prompt:l}),s(e=>{var i,t,o,n,r,s,a,l,c,d,p,_,m,g;return{...e,appmod_citations:[...null!==(i=e.appmod_citations)&&void 0!==i?i:[],...null!==(t=u.response.appmod_citations)&&void 0!==t?t:[]],audio_citations:[...null!==(o=e.audio_citations)&&void 0!==o?o:[],...null!==(n=u.response.audio_citations)&&void 0!==n?n:[]],file_citations:[...null!==(r=e.file_citations)&&void 0!==r?r:[],...null!==(s=u.response.file_citations)&&void 0!==s?s:[]],image_citations:[...null!==(a=e.image_citations)&&void 0!==a?a:[],...null!==(l=u.response.image_citations)&&void 0!==l?l:[]],rca_citations:[...null!==(c=e.rca_citations)&&void 0!==c?c:[],...null!==(d=u.response.rca_citations)&&void 0!==d?d:[]],web_citations:[...null!==(p=e.web_citations)&&void 0!==p?p:[],...null!==(_=u.response.web_citations)&&void 0!==_?_:[]],readfile_citations:[...null!==(m=e.readfile_citations)&&void 0!==m?m:[],...null!==(g=u.response.readfile_citations)&&void 0!==g?g:[]]}})}catch(i){console.error("[liblogs] processCitationsByBlock error — story:%s block:%s",e.storyNumber,e.blockNumber,i)}finally{let i=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}`;if(v.current.add(i),v.current.size===b.current.size){const e=a||y.current.gap_items_prompt,i=l||y.current.risk_items_prompt;f({finalGap:e,finalRisk:i,status:"complete"})}}}({...e,value:a,description:d},u,i),b.current.add(_)),{...e,value:a,description:d}}).filter(Boolean),l.forEach(e=>{r(i=>(i.find(i=>i.id===e.id)||i.push(e),[...i]))}),e.length>0&&e.map(({title:e,section:i,value:o,storyNumber:r,description:s,blockNumber:a,big_enough:l,big_enough_decision_factors:m,gapValue:f,confidenceScore:b,metadata:v},k)=>{n(n=>{var y,N,S,R,B,$,C,w;const O=n.findIndex(e=>e.storyNumber===r);if("intro"===i)-1===O?n.push({artifactId:`STORY-${r}-${a}`,title:e,value:o,description:s,storyNumber:r,sub_features:[],section:i,blockNumber:a,aiReasoning:g[k],big_enough:l,big_enough_decision_factors:m,gapValue:f,confidenceScore:b,metadata:v}):(n[O].value+=o,n[O].aiReasoning=n[O].aiReasoning||[],null===(N=null===(y=n[O])||void 0===y?void 0:y.aiReasoning)||void 0===N||N.push(...g[k]),n[O].big_enough=l,n[O].big_enough_decision_factors=m,n[O].gapValue=f,n[O].confidenceScore=b,n[O].metadata=v);else{n[O].sub_features||(n[O].sub_features=[]);const t=(null===(R=null===(S=n[O])||void 0===S?void 0:S.sub_features)||void 0===R?void 0:R.findIndex(e=>e.blockNumber===a))||-1;if(-1===t)null===($=null===(B=n[O])||void 0===B?void 0:B.sub_features)||void 0===$||$.push({artifactId:`STORY-${r}-${a}`,title:e,value:o,storyNumber:r,blockNumber:a,section:i,aiReasoning:g[k],big_enough:l,big_enough_decision_factors:m,gapValue:f,confidenceScore:b,metadata:v});else{let e=null===(w=null===(C=null==n?void 0:n[O])||void 0===C?void 0:C.sub_features)||void 0===w?void 0:w[t];e.value=(e.value||"")+o,e.aiReasoning=e.aiReasoning||[],e.aiReasoning.push(...g[k]),e.big_enough=l,e.big_enough_decision_factors=m,e.gapValue=f,e.confidenceScore=b,e.metadata=v}}const E=JSON.stringify(n);return h.current!==E&&(_({key:`streaming-redis-key-${t}`,value:{mmvf_list:n,knowledgeBase:u,projectAnalyserSummary:c,dataSources_files:d,ai_reasonings:p}}),h.current=E),[...n]})})}catch(e){console.error("Error in processing Stream Content",e)}}}}export{n as useStreamContentHandler};
1
+ import{useState as e,useRef as i,useEffect as t}from"react";import{processAIReasoningFromBlocks as o}from"../utils/proccess-stream.utils.js";function n({setUserStory:n,setAiReasoning:r,setUserStoryCitations:s,onStreamingCompleted:a,isGraphQLCallInProgress:l,knowledgeBase:u,projectAnalyserSummary:c,dataSourceFiles:d,aiReasoning:p,setRedisValue:_,fetchCitationByBlock:m,isOnDemandCitation:g}){const[f,b]=e({finalGap:"",finalRisk:"",status:"in-progress"}),v=i(new Set),h=i(new Set),k=i(null),y=i(null),N=i({gap_items_prompt:"",risk_items_prompt:""}),S=i(new Set);return t(()=>{"complete"!==f.status||l||(a(f.finalGap,f.finalRisk),v.current.clear(),h.current.clear(),k.current=null,y.current=null,N.current={gap_items_prompt:"",risk_items_prompt:""},S.current.clear(),b({finalGap:"",finalRisk:"",status:"in-progress"}))},[f,l]),{processStreamContent:function(e,i,t,l){try{const f=JSON.stringify(e);if(y.current===f)return;y.current=f;let R=[],B=[];e=e.map(e=>{var t;const n=`${(e={...e,subBlockNumber:null!==(t=e.subBlockNumber)&&void 0!==t?t:"1"}).storyNumber}-${e.blockNumber}-${e.subBlockNumber}`;if(S.current.has(n))return null;S.current.add(n);let{outputText:a,reasonings:l,gpt_citation:u,processedDescription:c}=o(e.value,e.blockNumber,e.storyNumber,e.description);s(e=>{var i;return u.length>0&&((null==e?void 0:e.gpt_citations)||(e.gpt_citations=[]),null===(i=e.gpt_citations)||void 0===i||i.push(...u)),{...e}}),R.push(...l),B.push([...l]);const d=l.filter(e=>e.on_demand).flatMap(e=>[...e.reason.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g),...e.gap.matchAll(/<a[^>]*href="([^"]+)\?type=on_demand"/g)].map(e=>{const[i,t]=e[1].split("$");return"book_citation_doc"!==i&&"book_citation_pdf"!==i&&"document_citation"!==i?null:{citation_number:t,customMetadata:{type:"document_citation"===i?"book_citation_pdf":i,file_name:"",fileType:"",gcs_upload_url:""}}}).filter(Boolean));d.length&&s(e=>{var i;return{...e,file_citations:[...null!==(i=e.file_citations)&&void 0!==i?i:[],...d]}});let p=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}<SUB_BLOCK>${e.subBlockNumber}`;return v.current.has(p)||(!async function(e,i,t){var o,n;let a="",l="";try{const u=await m(e,t,i);r(e=>{var i;const t=[...e];return null===(i=u.response.ai_reasonings)||void 0===i||i.forEach(e=>{const i=t.findIndex(i=>i.id===e.id);-1!==i&&e.gap.length>0&&e.reason.length>0&&(t[i]={...e})}),t}),a=(null===(o=u.response)||void 0===o?void 0:o.gap_items_prompt)||"",l=(null===(n=u.response)||void 0===n?void 0:n.risk_items_prompt)||"",(a||l)&&(N.current={gap_items_prompt:a,risk_items_prompt:l}),s(e=>{var i,t,o,n,r,s,a,l,c,d,p,_,m,g;return{...e,appmod_citations:[...null!==(i=e.appmod_citations)&&void 0!==i?i:[],...null!==(t=u.response.appmod_citations)&&void 0!==t?t:[]],audio_citations:[...null!==(o=e.audio_citations)&&void 0!==o?o:[],...null!==(n=u.response.audio_citations)&&void 0!==n?n:[]],file_citations:[...null!==(r=e.file_citations)&&void 0!==r?r:[],...null!==(s=u.response.file_citations)&&void 0!==s?s:[]],image_citations:[...null!==(a=e.image_citations)&&void 0!==a?a:[],...null!==(l=u.response.image_citations)&&void 0!==l?l:[]],rca_citations:[...null!==(c=e.rca_citations)&&void 0!==c?c:[],...null!==(d=u.response.rca_citations)&&void 0!==d?d:[]],web_citations:[...null!==(p=e.web_citations)&&void 0!==p?p:[],...null!==(_=u.response.web_citations)&&void 0!==_?_:[]],readfile_citations:[...null!==(m=e.readfile_citations)&&void 0!==m?m:[],...null!==(g=u.response.readfile_citations)&&void 0!==g?g:[]]}})}catch(i){console.error("[liblogs] processCitationsByBlock error — story:%s block:%s",e.storyNumber,e.blockNumber,i)}finally{let i=`<STORY_NUMBER>${e.storyNumber}<BLOCK_NUMBER>${e.blockNumber}`;if(h.current.add(i),h.current.size===v.current.size){const e=a||N.current.gap_items_prompt,i=l||N.current.risk_items_prompt;b({finalGap:e,finalRisk:i,status:"complete"})}}}({...e,value:a,description:c},l,i),v.current.add(p)),{...e,value:a,description:c}}).filter(Boolean),R.forEach(e=>{r(i=>(i.find(i=>i.id===e.id)||i.push(e),[...i]))}),e.length>0&&e.map(({title:e,section:i,value:o,storyNumber:r,description:s,blockNumber:a,big_enough:l,big_enough_decision_factors:m,gapValue:g,confidenceScore:f,metadata:b},v)=>{n(n=>{var h,y,N,S,R,$,C,O;const w=n.findIndex(e=>e.storyNumber===r);if("intro"===i)-1===w?n.push({artifactId:`STORY-${r}-${a}`,title:e,value:o,description:s,storyNumber:r,sub_features:[],section:i,blockNumber:a,aiReasoning:B[v],big_enough:l,big_enough_decision_factors:m,gapValue:g,confidenceScore:f,metadata:b}):(n[w].value+=o,n[w].aiReasoning=n[w].aiReasoning||[],null===(y=null===(h=n[w])||void 0===h?void 0:h.aiReasoning)||void 0===y||y.push(...B[v]),n[w].big_enough=l,n[w].big_enough_decision_factors=m,n[w].gapValue=g,n[w].confidenceScore=f,n[w].metadata=b);else{n[w].sub_features||(n[w].sub_features=[]);const t=(null===(S=null===(N=n[w])||void 0===N?void 0:N.sub_features)||void 0===S?void 0:S.findIndex(e=>e.blockNumber===a))||-1;if(-1===t)null===($=null===(R=n[w])||void 0===R?void 0:R.sub_features)||void 0===$||$.push({artifactId:`STORY-${r}-${a}`,title:e,value:o,storyNumber:r,blockNumber:a,section:i,aiReasoning:B[v],big_enough:l,big_enough_decision_factors:m,gapValue:g,confidenceScore:f,metadata:b});else{let e=null===(O=null===(C=null==n?void 0:n[w])||void 0===C?void 0:C.sub_features)||void 0===O?void 0:O[t];e.value=(e.value||"")+o,e.aiReasoning=e.aiReasoning||[],e.aiReasoning.push(...B[v]),e.big_enough=l,e.big_enough_decision_factors=m,e.gapValue=g,e.confidenceScore=f,e.metadata=b}}const E=JSON.stringify(n);return k.current!==E&&(_({key:`streaming-redis-key-${t}`,value:{mmvf_list:n,knowledgeBase:u,projectAnalyserSummary:c,dataSources_files:d,ai_reasonings:p}}),k.current=E),[...n]})}),l&&g&&a()}catch(e){console.error("Error in processing Stream Content",e)}}}}export{n as useStreamContentHandler};
2
2
  //# sourceMappingURL=useStreamContentHandler.js.map
@@ -1,2 +1,2 @@
1
- const e=e=>{const n=[];try{const t="<BLOCK_STREAM_START>",i="<BLOCK_STREAM_END>";let o=0;for(;;){const r=e.indexOf(t,o);if(-1===r)break;const s=e.indexOf(i,r+t.length);if(-1===s)break;const c=e.slice(r+t.length,s).trim();n.push(JSON.parse(c)),o=s+i.length}}catch(e){console.error("Error in extracting blocks from stream",e)}finally{return n}},n=e=>e.replace(/<onDemandCitation\s+type=(?:\\"|")([^"]+)(?:\\"|")\s+citationNo=(?:\\"|")(\d+)(?:\\"|")\s*(?:\/>|><\/onDemandCitation>)/g,(e,n,t)=>`<a href="${n}$${t}?type=on_demand">Source</a>`);function t(e,t,r,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>${r}`,v=!!d&&d.includes("type=on_demand"),O=function(e){const n=new Map,t="<gpt_citation ",i="</gpt_citation>";let o=0;for(;;){const r=e.indexOf(t,o);if(-1===r)break;const s=e.indexOf(">",r);if(-1===s)break;const c=e.indexOf(i,s);if(-1===c)break;const a=e.slice(r,c+i.length),l=e.slice(r,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+i.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())||"",N=(null===(g=null==T?void 0:T[2])||void 0===g?void 0:g.trim())||"";y=n(y),N=n(N),y=i(y,b),N=i(N,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:N,gapSource:(null===(m=null==T?void 0:T[1])||void 0===m?void 0:m.trim())||"",relevance_score:Number(null===($=null==x?void 0:x[1])||void 0===$?void 0:$.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 i(e,n){if(!e)return e;let t="",i=0;for(;;){const o=e.indexOf("<gpt_citation_here ",i);if(-1===o){t+=e.slice(i);break}t+=e.slice(i,o);const r=e.indexOf(">",o);if(-1===r){t+=e.slice(o);break}const s=e.slice(o,r+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>`}i=r+1}return t}function o(e,n){const t=n=>{const t=new RegExp(`<${n}>([\\s\\S]*?)<\\/${n}>`,"gi"),i=[];let o;for(;null!==(o=t.exec(e));)i.push(o[1].trim());return i},i=t("domain"),o=t("paraphrase");return{citation_number:n,customMetadata:{type:"gpt_citation",data_sources:t("data_sources"),training_data_title:i,paraphrase:o}}}const r=(e,n,t)=>{let i=e.includes("<h1><b>Title</b></h1>\n\n")?e:t?`<h1><b>Title</b></h1>\n\n${t} \n${e}`:e;return i=i.includes("<h1><b>Requirement Type</b></h1>\n\n")?i:n?`<h1><b>Requirement Type</b></h1>\n\n${n} \n${i}`:i,i};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,r as processUserStoryValue,i as replaceGptCitation};
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\s+href=(?:\\"|")([^"]+)(?:\\"|")\s+source=(?:\\"|")([^"]+)(?:\\"|")\s+type=(?:\\"|")([^"]+)(?:\\"|")\s+citationNo=(?:\\"|")(\d+)(?:\\"|")\s*(?:\/>|><\/onDemandCitation>)/g,(e,n,t,r,o)=>`<a href="${n||`${r}$${o}?type=on_demand`}" source="${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())||"",N=(null===(g=null==T?void 0:T[2])||void 0===g?void 0:g.trim())||"";y=n(y),N=n(N),y=r(y,b),N=r(N,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:N,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
@@ -33,9 +33,10 @@ interface IProps {
33
33
  };
34
34
  aiReasoning: TAIReasoning[];
35
35
  fetchCitationByBlock: (block: BlockStreamItem, metadata: any, ai_reasonings: TAIReasoning[]) => Promise<IGetCitationsByBlock>;
36
+ isOnDemandCitation?: boolean;
36
37
  }
37
- export declare function useStreamContentHandler({ setUserStory, setAiReasoning, setUserStoryCitations, onStreamingCompleted, isGraphQLCallInProgress, knowledgeBase, projectAnalyserSummary, dataSourceFiles, aiReasoning, setRedisValue, fetchCitationByBlock }: IProps): {
38
- processStreamContent: (blockList: BlockStreamItem[], customMetadata: any, storyArtifactID: string) => void;
38
+ export declare function useStreamContentHandler({ setUserStory, setAiReasoning, setUserStoryCitations, onStreamingCompleted, isGraphQLCallInProgress, knowledgeBase, projectAnalyserSummary, dataSourceFiles, aiReasoning, setRedisValue, fetchCitationByBlock, isOnDemandCitation }: IProps): {
39
+ processStreamContent: (blockList: BlockStreamItem[], customMetadata: any, storyArtifactID: string, isStoryStreamingCompleted?: boolean) => void;
39
40
  };
40
41
  export {};
41
42
  //# sourceMappingURL=useStreamContentHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStreamContentHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/features/RequirementAI/hooks/useStreamContentHandler.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGrF,MAAM,MAAM,eAAe,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B,CAAC,EAAE,wBAAwB,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAC,OAAO,CAAC,CAAC;CACrC,CAAC;AAEF,UAAU,MAAM;IACZ,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACrE,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACjE,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACrE,qBAAqB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChF,oBAAoB,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/F,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,GAAG,CAAC;IACnB,sBAAsB,EAAE,GAAG,CAAC;IAC5B,eAAe,EAAE;QACb,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;IACF,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,oBAAoB,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjI;AAED,wBAAgB,uBAAuB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAoB,EAAE,EAAE,MAAM;sCAgF7O,eAAe,EAAE,kBACZ,GAAG,mBACF,MAAM;EAgO9B"}
1
+ {"version":3,"file":"useStreamContentHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/features/RequirementAI/hooks/useStreamContentHandler.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGrF,MAAM,MAAM,eAAe,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B,CAAC,EAAE,wBAAwB,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAC,OAAO,CAAC,CAAC;CACrC,CAAC;AAEF,UAAU,MAAM;IACZ,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACrE,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACjE,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACrE,qBAAqB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChF,oBAAoB,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/F,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,GAAG,CAAC;IACnB,sBAAsB,EAAE,GAAG,CAAC;IAC5B,eAAe,EAAE;QACb,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;IACF,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,oBAAoB,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9H,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,wBAAgB,uBAAuB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,EAAE,MAAM;sCAgFjQ,eAAe,EAAE,kBACZ,GAAG,mBACF,MAAM,8BACK,OAAO;EAoO1C"}
@@ -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;AAYD,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"}
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;AAcD,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/requirement-ai",
3
- "version": "0.0.287",
3
+ "version": "0.0.289",
4
4
  "author": "Saptyadeep Bhattacharjee",
5
5
  "description": "",
6
6
  "license": "MIT",