@e-llm-studio/citation 0.0.220 → 0.0.221-beta.2
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/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/cjs/features/RulebookCitations/RuleBookCitationApi.js +1 -1
- package/dist/cjs/features/RulebookCitations/RuleBookCitationWrapper.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitation.js +1 -1
- package/dist/features/RulebookCitations/RuleBookCitationApi.js +1 -1
- package/dist/features/RulebookCitations/RuleBookCitationWrapper.js +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/dist/types/src/features/GptWebCitation/GptWebCitation.d.ts.map +1 -1
- package/dist/types/src/features/RulebookCitations/RuleBookCitationApi.d.ts +3 -14
- package/dist/types/src/features/RulebookCitations/RuleBookCitationApi.d.ts.map +1 -1
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapper.d.ts +13 -4
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapper.d.ts.map +1 -1
- package/dist/types/src/features/RulebookCitations/RuleBookCitationWrapperTest.d.ts.map +1 -1
- package/package.json +6 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react"),o=require("../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js"),l=require("./GptWebCitationImageCitation.js"),a=require("./GptWebCitationSkeleton.js"),s=require("./types.js"),r=require("./utils/citationData.utils.js"),u=require("./utils/styleOverrides.utils.js"),d=require("./utils/fixedHeight.utils.js"),g=require("./GptWebCitation.module.css.js"),c=require("../../assests/svg/NeuralNetworkIcon.js"),v=function(t){var o=t.variant,l=t.disabled,a=t.onClick,s=t.title,r=t.style;return i.jsx("button",e.__assign({type:"button",className:g.default.webCitationButton,onClick:a,disabled:l,title:s,style:r},{children:"gpt"===o?i.jsxs(i.Fragment,{children:[i.jsx(c.default,{className:g.default.webCitationButtonIcon}),"View GPT Citation"]}):i.jsxs(i.Fragment,{children:[i.jsx(n.Globe,{size:24,className:g.default.webCitationButtonIcon}),"View Web Citation"]})}))};exports.default=function(c){var p,C,b,_=c.gptCitation,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react"),o=require("../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js"),l=require("./GptWebCitationImageCitation.js"),a=require("./GptWebCitationSkeleton.js"),s=require("./types.js"),r=require("./utils/citationData.utils.js"),u=require("./utils/styleOverrides.utils.js"),d=require("./utils/fixedHeight.utils.js"),g=require("./GptWebCitation.module.css.js"),c=require("../../assests/svg/NeuralNetworkIcon.js"),v=function(t){var o=t.variant,l=t.disabled,a=t.onClick,s=t.title,r=t.style;return i.jsx("button",e.__assign({type:"button",className:g.default.webCitationButton,onClick:a,disabled:l,title:s,style:r},{children:"gpt"===o?i.jsxs(i.Fragment,{children:[i.jsx(c.default,{className:g.default.webCitationButtonIcon}),"View GPT Citation"]}):i.jsxs(i.Fragment,{children:[i.jsx(n.Globe,{size:24,className:g.default.webCitationButtonIcon}),"View Web Citation"]})}))};exports.default=function(c){var p,C,b,_,w=c.gptCitation,f=c.defaultCitationUrl,m=c.citationType,x=c.webCitationData,y=c.topic,h=c.sourceLabel,k=c.relevanceScore,j=c.learnedFrom,F=c.webCitationStatus,S=c.onGenerateWebCitation,I=c.showWebCitation,L=c.onToggleCitationView,W=c.showExpandImageButton,B=void 0===W||W,H=c.showGptMaximizeButton,T=c.iconsConfig,N=c.isFixedHeight,V=void 0!==N&&N,M=c.styles,q=t.useMemo(function(){return function(i){var t,n,o,l,a,s,r,d,g,c,v;return{container:null==i?void 0:i.container,gptWrapper:e.__assign(e.__assign({},null===(t=null==i?void 0:i.gptCitation)||void 0===t?void 0:t.wrapper),null==i?void 0:i.gptCitationWrapper),gptFooterAction:e.__assign(e.__assign({},null===(n=null==i?void 0:i.gptCitation)||void 0===n?void 0:n.footerAction),null==i?void 0:i.footerAction),gptToggleButton:e.__assign(e.__assign({},null===(o=null==i?void 0:i.gptCitation)||void 0===o?void 0:o.toggleButton),null==i?void 0:i.webCitationButton),webPanel:e.__assign(e.__assign({},null==i?void 0:i.container),null===(l=null==i?void 0:i.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==i?void 0:i.webCitation)||void 0===a?void 0:a.header,webContent:null===(s=null==i?void 0:i.webCitation)||void 0===s?void 0:s.content,webFooter:null===(r=null==i?void 0:i.webCitation)||void 0===r?void 0:r.footer,webToggleButton:e.__assign(e.__assign({},null===(d=null==i?void 0:i.webCitation)||void 0===d?void 0:d.toggleButton),null==i?void 0:i.webCitationButton),webLearnedFrom:null===(g=null==i?void 0:i.webCitation)||void 0===g?void 0:g.learnedFrom,webImage:null===(c=null==i?void 0:i.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==i?void 0:i.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"image"),webSkeletonVisitLink:u.resolveWebCitationVisitLinkStyles(null==i?void 0:i.webCitation,"skeleton")}}(M)},[M]),E=s.allowsGptCitationView(m),G=s.allowsWebCitationView(m),z=s.showsCitationViewToggle(m),U=t.useMemo(function(){return V?d.resolveFixedHeightLayout(w.bodyHeight,z):null},[V,w.bodyHeight,z]),A=t.useMemo(function(){return U?d.getFixedPanelStyle(U.panelHeight):void 0},[U]),D=t.useMemo(function(){var e,i;return{MaximizeIcon:null!==(e=null==T?void 0:T.MaximizeIcon)&&void 0!==e?e:null===(i=w.iconsConfig)||void 0===i?void 0:i.MaximizeIcon,ExternalLinkIcon:null==T?void 0:T.ExternalLinkIcon}},[T,null===(p=w.iconsConfig)||void 0===p?void 0:p.MaximizeIcon]),P=t.useMemo(function(){return e.__assign(e.__assign(e.__assign(e.__assign({},w),V&&U?{bodyHeight:U.gptBodyHeight}:{}),{disableMaximize:void 0!==H?!H:w.disableMaximize}),z||m===s.CitationType.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[w,H,z,m,V,U]),O=t.useState(m!==s.CitationType.GPT),R=O[0],J=O[1],K=m!==s.CitationType.GPT&&(m===s.CitationType.WEB||(null!=I?I:R)),Q=void 0!==I,X=t.useMemo(function(){return x?r.mapCitationDataToDisplay(x):null},[x]),Y=null!==(C=null!=y?y:null==X?void 0:X.topic)&&void 0!==C?C:"Web Citation",Z=null!==(b=null!=k?k:null==X?void 0:X.relevanceScore)&&void 0!==b?b:0,$=null!=j?j:null==X?void 0:X.learnedFrom,ee=r.resolveSkeletonVisitUrl(null==X?void 0:X.highlightedUrl,null!==(_=null==X?void 0:X.citationUrl)&&void 0!==_?_:f),ie=r.getWebCitationImageUrl(x),te=t.useMemo(function(){return function(e,i,t){return t?"success":e||(i?"error":"pending")}(F,x,ie)},[F,x,ie]),ne=t.useCallback(function(){L?L():Q||J(!1)},[L,Q]),oe=t.useCallback(function(){L?L():Q||J(!0),ie||"success"===te||null==S||S()},[L,Q,ie,te,S]),le=null!=h?h:"Source: Web Citation > ".concat(Y),ae=function(t){var n=!!P.DocumentTitle,l=[g.default.gptCitationWrapper,n?g.default.gptCitationWrapperWithSource:"",V?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return i.jsxs("div",e.__assign({className:l,style:e.__assign(e.__assign({},q.gptWrapper),A)},{children:[i.jsx(o.default,e.__assign({},P,{splitterCustomStyle:!0})),t&&(n?i.jsx("div",e.__assign({className:g.default.gptCitationFooterAction,style:q.gptFooterAction},{children:t})):i.jsx("div",e.__assign({className:[g.default.gptCitationToggleFooter,V?g.default.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:q.gptFooterAction},{children:t})))]}))};return E&&!K?i.jsx("div",e.__assign({className:g.default.overlay,style:q.container},{children:ae(z?i.jsx(v,{variant:"web",onClick:oe,title:"View web-based citation for this source.",style:q.gptToggleButton}):void 0)})):G?i.jsxs("div",e.__assign({className:[g.default.panel,V?g.default.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},q.webPanel),A)},{children:[i.jsxs("div",e.__assign({className:g.default.panelHeader,style:q.webHeader},{children:[i.jsx("span",e.__assign({className:g.default.panelSource},{children:le})),i.jsx("div",e.__assign({className:g.default.panelHeaderActions},{children:Z>0&&i.jsxs("div",e.__assign({className:g.default.confidenceBadge,title:"Decision strength"},{children:[i.jsx(n.Sparkles,{size:14}),Z,"%"]}))}))]})),i.jsx("div",e.__assign({className:[g.default.panelContent,g.default.panelContentExpanded,V?g.default.panelContentFixedHeight:""].filter(Boolean).join(" "),style:e.__assign(e.__assign({},q.webContent),V?d.getFixedWebContentStyle():void 0)},{children:"pending"===te?i.jsx(a.default,{status:"pending",citationUrl:ee,ExternalLinkIcon:D.ExternalLinkIcon,styles:q.webSkeleton,visitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:V}):"success"===te&&ie?i.jsx(l.default,{citationImage:ie,citationUrl:ee,showExpandImageButton:B,iconsConfig:D,styles:q.webImage,visitLinkStyles:q.webImageVisitLink,skeletonStyles:q.webSkeleton,skeletonVisitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:V}):i.jsx(a.default,{status:"error",citationUrl:ee,ExternalLinkIcon:D.ExternalLinkIcon,styles:q.webSkeleton,visitLinkStyles:q.webSkeletonVisitLink,isFixedHeight:V})})),i.jsxs("div",e.__assign({className:g.default.panelFooter,style:q.webFooter},{children:[z?i.jsx(v,{variant:"gpt",onClick:ne,style:q.webToggleButton}):null,$&&i.jsxs("span",e.__assign({className:g.default.learnedFrom,style:q.webLearnedFrom},{children:["Learned From ",$]}))]}))]})):i.jsx("div",e.__assign({className:g.default.overlay,style:q.container},{children:ae()}))};
|
|
2
2
|
//# sourceMappingURL=GptWebCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");exports.getFileContent=function(t,n){var r,o;return e.__awaiter(this,void 0,void 0,function(){var i,s;return e.__generator(this,function(e){switch(e.label){case 0:return[4,fetch("".concat(n,"/gcs/get-file-content"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({file_path:t})})];case 1:if(!(i=e.sent()).ok)throw new Error("Failed to fetch file content: ".concat(i.statusText));return[4,i.json()];case 2:return s=e.sent(),[2,null!==(o=null===(r=null==s?void 0:s.responseData)||void 0===r?void 0:r.content)&&void 0!==o?o:""]}})})},exports.getNestedValue=function(e,t){var n;try{for(var r=t.split("."),o=e,i=0,s=r;i<s.length;i++){var a=s[i],l=a.match(/^(\w+)\[(\d+)\]$/);if(l){var c=l[1],u=l[2];o=null===(n=null==o?void 0:o[c])||void 0===n?void 0:n[Number(u)]}else o=null==o?void 0:o[a];if(null==o)return null}return o}catch(e){return console.error("Nested extraction error",e),null}},exports.getSignedUrl=function(t,n){return e.__awaiter(this,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,fetch("".concat(n,"/gcs/get-signed-url/"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({gsutil_url:t})})];case 1:if(!(r=e.sent()).ok)throw new Error("Failed to get signed URL: ".concat(r.statusText));return[4,r.json()];case 2:return[2,e.sent()]}})})},exports.isJSONFile=function(e){var t;return null!==(t=null==e?void 0:e.toLowerCase().includes("json"))&&void 0!==t&&t};
|
|
2
2
|
//# sourceMappingURL=RuleBookCitationApi.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),l=require("react"),n=require("lucide-react"),t=require("../TextualGuidelines/TextualGuideLinesComponent.js"),r=require("./RuleBookCitationApi.js");exports.default=function(a){var o,s,d,u,c,v=a.data,f=a.msg,g=a.citationIndex,h=a.guidelines,p=void 0===h?[]:h,x=a.url,_=a.additionalClassNames;console.log("Latest code");var m=null!==(s=null!==(o=null==v?void 0:v.citationNumber)&&void 0!==o?o:g)&&void 0!==s?s:0,b=(null==f?void 0:f.requestId)||(null==f?void 0:f.id)||"",j=l.useState(null),y=j[0],C=j[1],S=l.useState(null),D=S[0],k=S[1],q=l.useState(null),w=q[0],N=q[1],L=l.useState(!1),A=L[0],R=L[1],T=l.useState(null),B=T[0],E=T[1];l.useEffect(function(){var e,i,l,n;if(!y){if(null===(e=null==v?void 0:v.fileDetails)||void 0===e?void 0:e.file_id)return E(null),C(v.fileDetails.file_id),void k(v.fileDetails.phrase_to_highlight||null);var t=(null!==(n=null===(l=null===(i=null==f?void 0:f.artifactSearchData)||void 0===i?void 0:i.ruleBookData)||void 0===l?void 0:l.rulebook_citations)&&void 0!==n?n:[])[m];if(!t)return E("Citation not found at the specified index."),C(null),void k(null);if(!t.file_id)return E("Citation data is missing file_id."),C(null),void k(null);N(null),E(null),C(t.file_id),k(t.phrase_to_highlight||null)}},[b,m,y,null===(d=null==v?void 0:v.fileDetails)||void 0===d?void 0:d.file_id,null===(u=null==v?void 0:v.fileDetails)||void 0===u?void 0:u.phrase_to_highlight]),l.useEffect(function(){if(y){var i=Array.isArray(p)?p:Object.values(p||{}).flat();e.__awaiter(void 0,void 0,void 0,function(){var l,n,t,a,o,s,d,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!(null==(l=i.find(function(e){return e.id===y}))?void 0:l.gcsUrl))return[2];e.label=1;case 1:return e.trys.push([1,4,5,6]),R(!0),E(null),[4,r.getSignedUrl(l.gcsUrl,x)];case 2:if(null==(n=e.sent())?void 0:n.error)throw new Error(n.error);return t=(null===(u=l.name)||void 0===u?void 0:u.toLowerCase().split(".").pop())||"",r.isJSONFile(t)?[4,r.getFileContent(l.gcsUrl,x)]:[2];case 3:return a=e.sent(),o=JSON.parse(a),s=r.getNestedValue(o,"data.artifactData.userStorySnapshot[0].value"),N(s||""),[3,6];case 4:return d=e.sent(),console.error(d),E(d.message||"An error occurred while loading file contents."),N(null),[3,6];case 5:return R(!1),[7];case 6:return[2]}})})}else N(null)},[y,p,x]);var G=A,H=(null==w?void 0:w.replace(/\\\./g,"."))||"";return i.jsxs("div",e.__assign({className:null!==(c=null==_?void 0:_.container)&&void 0!==c?c:"",style:{width:"100%",minHeight:"100px"}},{children:[G&&i.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px",gap:"8px"}},{children:[i.jsx(n.Loader2,{style:{animation:"spin 1s linear infinite"},size:24}),i.jsx("span",{children:"Loading content..."})]})),B&&!G&&i.jsxs("div",e.__assign({style:{padding:"12px",backgroundColor:"#fee2e2",border:"1px solid #fca5a5",borderRadius:"4px",color:"#991b1b",marginBottom:"12px"}},{children:[i.jsx("strong",{children:"Error:"})," ",B]})),!G&&!B&&w&&i.jsx("div",e.__assign({style:{marginTop:"12px"}},{children:i.jsx(t.default,{TextualGuideLines:H,HighlightedWords:D?[D]:[],InternalGptReasoningData:[],index:0,headerTitle:"Rule Book Citation",useVariantHighlight:!1})})),!G&&!B&&!w&&i.jsx("div",e.__assign({style:{padding:"12px",backgroundColor:"#f3f4f6",border:"1px solid #d1d5db",borderRadius:"4px",color:"#6b7280",textAlign:"center"}},{children:"No content available."})),i.jsx("style",{children:"\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n "})]}))};
|
|
2
2
|
//# sourceMappingURL=RuleBookCitationWrapper.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as p,showsCitationViewToggle as g,CitationType as m}from"./types.js";import{mapCitationDataToDisplay as b,resolveSkeletonVisitUrl as C,getWebCitationImageUrl as w}from"./utils/citationData.utils.js";import{resolveWebCitationVisitLinkStyles as f}from"./utils/styleOverrides.utils.js";import{resolveFixedHeightLayout as h,getFixedPanelStyle as k,getFixedWebContentStyle as y}from"./utils/fixedHeight.utils.js";import x from"./GptWebCitation.module.css.js";import F from"../../assests/svg/NeuralNetworkIcon.js";var I=function(o){var l=o.variant,a=o.disabled,r=o.onClick,d=o.title,u=o.style;return t("button",i({type:"button",className:x.webCitationButton,onClick:r,disabled:a,title:d,style:u},{children:e(n,"gpt"===l?{children:[t(F,{className:x.webCitationButtonIcon}),"View GPT Citation"]}:{children:[t(s,{size:24,className:x.webCitationButtonIcon}),"View Web Citation"]})}))},B=function(n){var s,F,B,S=n.gptCitation,
|
|
1
|
+
import{__assign as i}from"tslib";import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useMemo as o,useState as l,useCallback as a}from"react";import{Sparkles as r,Globe as s}from"lucide-react";import d from"../CognitiveInternalgptReasoning/CognitiveInternalgptCoreComponent.js";import u from"./GptWebCitationImageCitation.js";import c from"./GptWebCitationSkeleton.js";import{allowsGptCitationView as v,allowsWebCitationView as p,showsCitationViewToggle as g,CitationType as m}from"./types.js";import{mapCitationDataToDisplay as b,resolveSkeletonVisitUrl as C,getWebCitationImageUrl as w}from"./utils/citationData.utils.js";import{resolveWebCitationVisitLinkStyles as f}from"./utils/styleOverrides.utils.js";import{resolveFixedHeightLayout as h,getFixedPanelStyle as k,getFixedWebContentStyle as y}from"./utils/fixedHeight.utils.js";import x from"./GptWebCitation.module.css.js";import F from"../../assests/svg/NeuralNetworkIcon.js";var I=function(o){var l=o.variant,a=o.disabled,r=o.onClick,d=o.title,u=o.style;return t("button",i({type:"button",className:x.webCitationButton,onClick:r,disabled:a,title:d,style:u},{children:e(n,"gpt"===l?{children:[t(F,{className:x.webCitationButtonIcon}),"View GPT Citation"]}:{children:[t(s,{size:24,className:x.webCitationButtonIcon}),"View Web Citation"]})}))},B=function(n){var s,F,B,S,L=n.gptCitation,H=n.defaultCitationUrl,N=n.citationType,W=n.webCitationData,j=n.topic,T=n.sourceLabel,E=n.relevanceScore,V=n.learnedFrom,z=n.webCitationStatus,G=n.onGenerateWebCitation,A=n.showWebCitation,M=n.onToggleCitationView,U=n.showExpandImageButton,D=void 0===U||U,P=n.showGptMaximizeButton,O=n.iconsConfig,R=n.isFixedHeight,q=void 0!==R&&R,J=n.styles,K=o(function(){return function(t){var e,n,o,l,a,r,s,d,u,c,v;return{container:null==t?void 0:t.container,gptWrapper:i(i({},null===(e=null==t?void 0:t.gptCitation)||void 0===e?void 0:e.wrapper),null==t?void 0:t.gptCitationWrapper),gptFooterAction:i(i({},null===(n=null==t?void 0:t.gptCitation)||void 0===n?void 0:n.footerAction),null==t?void 0:t.footerAction),gptToggleButton:i(i({},null===(o=null==t?void 0:t.gptCitation)||void 0===o?void 0:o.toggleButton),null==t?void 0:t.webCitationButton),webPanel:i(i({},null==t?void 0:t.container),null===(l=null==t?void 0:t.webCitation)||void 0===l?void 0:l.panel),webHeader:null===(a=null==t?void 0:t.webCitation)||void 0===a?void 0:a.header,webContent:null===(r=null==t?void 0:t.webCitation)||void 0===r?void 0:r.content,webFooter:null===(s=null==t?void 0:t.webCitation)||void 0===s?void 0:s.footer,webToggleButton:i(i({},null===(d=null==t?void 0:t.webCitation)||void 0===d?void 0:d.toggleButton),null==t?void 0:t.webCitationButton),webLearnedFrom:null===(u=null==t?void 0:t.webCitation)||void 0===u?void 0:u.learnedFrom,webImage:null===(c=null==t?void 0:t.webCitation)||void 0===c?void 0:c.image,webSkeleton:null===(v=null==t?void 0:t.webCitation)||void 0===v?void 0:v.skeleton,webImageVisitLink:f(null==t?void 0:t.webCitation,"image"),webSkeletonVisitLink:f(null==t?void 0:t.webCitation,"skeleton")}}(J)},[J]),Q=v(N),X=p(N),Y=g(N),Z=o(function(){return q?h(L.bodyHeight,Y):null},[q,L.bodyHeight,Y]),$=o(function(){return Z?k(Z.panelHeight):void 0},[Z]),_=o(function(){var i,t;return{MaximizeIcon:null!==(i=null==O?void 0:O.MaximizeIcon)&&void 0!==i?i:null===(t=L.iconsConfig)||void 0===t?void 0:t.MaximizeIcon,ExternalLinkIcon:null==O?void 0:O.ExternalLinkIcon}},[O,null===(s=L.iconsConfig)||void 0===s?void 0:s.MaximizeIcon]),ii=o(function(){return i(i(i(i({},L),q&&Z?{bodyHeight:Z.gptBodyHeight}:{}),{disableMaximize:void 0!==P?!P:L.disableMaximize}),Y||N===m.WEB?{DocumentTitle:void 0,previewCallback:void 0}:{})},[L,P,Y,N,q,Z]),ti=l(N!==m.GPT),ei=ti[0],ni=ti[1],oi=N!==m.GPT&&(N===m.WEB||(null!=A?A:ei)),li=void 0!==A,ai=o(function(){return W?b(W):null},[W]),ri=null!==(F=null!=j?j:null==ai?void 0:ai.topic)&&void 0!==F?F:"Web Citation",si=null!==(B=null!=E?E:null==ai?void 0:ai.relevanceScore)&&void 0!==B?B:0,di=null!=V?V:null==ai?void 0:ai.learnedFrom,ui=C(null==ai?void 0:ai.highlightedUrl,null!==(S=null==ai?void 0:ai.citationUrl)&&void 0!==S?S:H),ci=w(W),vi=o(function(){return function(i,t,e){return e?"success":i||(t?"error":"pending")}(z,W,ci)},[z,W,ci]),pi=a(function(){M?M():li||ni(!1)},[M,li]),gi=a(function(){M?M():li||ni(!0),ci||"success"===vi||null==G||G()},[M,li,ci,vi,G]),mi=null!=T?T:"Source: Web Citation > ".concat(ri),bi=function(n){var o=!!ii.DocumentTitle,l=[x.gptCitationWrapper,o?x.gptCitationWrapperWithSource:"",q?x.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" ");return e("div",i({className:l,style:i(i({},K.gptWrapper),$)},{children:[t(d,i({},ii,{splitterCustomStyle:!0})),n&&t("div",i(o?{className:x.gptCitationFooterAction,style:K.gptFooterAction}:{className:[x.gptCitationToggleFooter,q?x.gptCitationToggleFooterFixedHeight:""].filter(Boolean).join(" "),style:K.gptFooterAction},{children:n}))]}))};return Q&&!oi?t("div",i({className:x.overlay,style:K.container},{children:bi(Y?t(I,{variant:"web",onClick:gi,title:"View web-based citation for this source.",style:K.gptToggleButton}):void 0)})):X?e("div",i({className:[x.panel,q?x.gptCitationWrapperFixedHeight:""].filter(Boolean).join(" "),style:i(i({},K.webPanel),$)},{children:[e("div",i({className:x.panelHeader,style:K.webHeader},{children:[t("span",i({className:x.panelSource},{children:mi})),t("div",i({className:x.panelHeaderActions},{children:si>0&&e("div",i({className:x.confidenceBadge,title:"Decision strength"},{children:[t(r,{size:14}),si,"%"]}))}))]})),t("div",i({className:[x.panelContent,x.panelContentExpanded,q?x.panelContentFixedHeight:""].filter(Boolean).join(" "),style:i(i({},K.webContent),q?y():void 0)},{children:"pending"===vi?t(c,{status:"pending",citationUrl:ui,ExternalLinkIcon:_.ExternalLinkIcon,styles:K.webSkeleton,visitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q}):"success"===vi&&ci?t(u,{citationImage:ci,citationUrl:ui,showExpandImageButton:D,iconsConfig:_,styles:K.webImage,visitLinkStyles:K.webImageVisitLink,skeletonStyles:K.webSkeleton,skeletonVisitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q}):t(c,{status:"error",citationUrl:ui,ExternalLinkIcon:_.ExternalLinkIcon,styles:K.webSkeleton,visitLinkStyles:K.webSkeletonVisitLink,isFixedHeight:q})})),e("div",i({className:x.panelFooter,style:K.webFooter},{children:[Y?t(I,{variant:"gpt",onClick:pi,style:K.webToggleButton}):null,di&&e("span",i({className:x.learnedFrom,style:K.webLearnedFrom},{children:["Learned From ",di]}))]}))]})):t("div",i({className:x.overlay,style:K.container},{children:bi()}))};export{B as default};
|
|
2
2
|
//# sourceMappingURL=GptWebCitation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as
|
|
1
|
+
import{__awaiter as t,__generator as n}from"tslib";function e(t){var n;return null!==(n=null==t?void 0:t.toLowerCase().includes("json"))&&void 0!==n&&n}function r(e,r){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,fetch("".concat(r,"/gcs/get-signed-url/"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({gsutil_url:e})})];case 1:if(!(t=n.sent()).ok)throw new Error("Failed to get signed URL: ".concat(t.statusText));return[4,t.json()];case 2:return[2,n.sent()]}})})}function o(e,r){var o,i;return t(this,void 0,void 0,function(){var t,c;return n(this,function(n){switch(n.label){case 0:return[4,fetch("".concat(r,"/gcs/get-file-content"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({file_path:e})})];case 1:if(!(t=n.sent()).ok)throw new Error("Failed to fetch file content: ".concat(t.statusText));return[4,t.json()];case 2:return c=n.sent(),[2,null!==(i=null===(o=null==c?void 0:c.responseData)||void 0===o?void 0:o.content)&&void 0!==i?i:""]}})})}function i(t,n){var e;try{for(var r=n.split("."),o=t,i=0,c=r;i<c.length;i++){var l=c[i],s=l.match(/^(\w+)\[(\d+)\]$/);if(s){var a=s[1],u=s[2];o=null===(e=null==o?void 0:o[a])||void 0===e?void 0:e[Number(u)]}else o=null==o?void 0:o[l];if(null==o)return null}return o}catch(t){return console.error("Nested extraction error",t),null}}export{o as getFileContent,i as getNestedValue,r as getSignedUrl,e as isJSONFile};
|
|
2
2
|
//# sourceMappingURL=RuleBookCitationApi.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as i,__awaiter as e,__generator as l}from"tslib";import{jsxs as n,jsx as r}from"react/jsx-runtime";import{useState as t,useEffect as o}from"react";import{Loader2 as a}from"lucide-react";import d from"../TextualGuidelines/TextualGuideLinesComponent.js";import{getNestedValue as s,isJSONFile as u,getFileContent as c,getSignedUrl as f}from"./RuleBookCitationApi.js";var v=function(v){var p,g,h,m,x,b=v.data,y=v.msg,_=v.citationIndex,C=v.guidelines,D=void 0===C?[]:C,k=v.url,w=v.additionalClassNames;console.log("Latest code");var j=null!==(g=null!==(p=null==b?void 0:b.citationNumber)&&void 0!==p?p:_)&&void 0!==g?g:0,A=(null==y?void 0:y.requestId)||(null==y?void 0:y.id)||"",L=t(null),N=L[0],R=L[1],T=t(null),B=T[0],G=T[1],H=t(null),I=H[0],S=H[1],U=t(!1),E=U[0],O=U[1],q=t(null),z=q[0],J=q[1];o(function(){var i,e,l,n;if(!N){if(null===(i=null==b?void 0:b.fileDetails)||void 0===i?void 0:i.file_id)return J(null),R(b.fileDetails.file_id),void G(b.fileDetails.phrase_to_highlight||null);var r=(null!==(n=null===(l=null===(e=null==y?void 0:y.artifactSearchData)||void 0===e?void 0:e.ruleBookData)||void 0===l?void 0:l.rulebook_citations)&&void 0!==n?n:[])[j];if(!r)return J("Citation not found at the specified index."),R(null),void G(null);if(!r.file_id)return J("Citation data is missing file_id."),R(null),void G(null);S(null),J(null),R(r.file_id),G(r.phrase_to_highlight||null)}},[A,j,N,null===(h=null==b?void 0:b.fileDetails)||void 0===h?void 0:h.file_id,null===(m=null==b?void 0:b.fileDetails)||void 0===m?void 0:m.phrase_to_highlight]),o(function(){if(N){var i=Array.isArray(D)?D:Object.values(D||{}).flat();e(void 0,void 0,void 0,function(){var e,n,r,t,o,a,d,v;return l(this,function(l){switch(l.label){case 0:if(!(null==(e=i.find(function(i){return i.id===N}))?void 0:e.gcsUrl))return[2];l.label=1;case 1:return l.trys.push([1,4,5,6]),O(!0),J(null),[4,f(e.gcsUrl,k)];case 2:if(null==(n=l.sent())?void 0:n.error)throw new Error(n.error);return r=(null===(v=e.name)||void 0===v?void 0:v.toLowerCase().split(".").pop())||"",u(r)?[4,c(e.gcsUrl,k)]:[2];case 3:return t=l.sent(),o=JSON.parse(t),a=s(o,"data.artifactData.userStorySnapshot[0].value"),S(a||""),[3,6];case 4:return d=l.sent(),console.error(d),J(d.message||"An error occurred while loading file contents."),S(null),[3,6];case 5:return O(!1),[7];case 6:return[2]}})})}else S(null)},[N,D,k]);var V=E,W=(null==I?void 0:I.replace(/\\\./g,"."))||"";return n("div",i({className:null!==(x=null==w?void 0:w.container)&&void 0!==x?x:"",style:{width:"100%",minHeight:"100px"}},{children:[V&&n("div",i({style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100px",gap:"8px"}},{children:[r(a,{style:{animation:"spin 1s linear infinite"},size:24}),r("span",{children:"Loading content..."})]})),z&&!V&&n("div",i({style:{padding:"12px",backgroundColor:"#fee2e2",border:"1px solid #fca5a5",borderRadius:"4px",color:"#991b1b",marginBottom:"12px"}},{children:[r("strong",{children:"Error:"})," ",z]})),!V&&!z&&I&&r("div",i({style:{marginTop:"12px"}},{children:r(d,{TextualGuideLines:W,HighlightedWords:B?[B]:[],InternalGptReasoningData:[],index:0,headerTitle:"Rule Book Citation",useVariantHighlight:!1})})),!V&&!z&&!I&&r("div",i({style:{padding:"12px",backgroundColor:"#f3f4f6",border:"1px solid #d1d5db",borderRadius:"4px",color:"#6b7280",textAlign:"center"}},{children:"No content available."})),r("style",{children:"\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n "})]}))};export{v as default};
|
|
2
2
|
//# sourceMappingURL=RuleBookCitationWrapper.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare const useCompareLayout: (initialMaintainOrder: boolean, scrollContainerRef: React.RefObject<HTMLDivElement>, lhsBadgeRefs: any, rhsBadgeRefs: any, proposedSections: any[], existingSections: any[]) => {
|
|
3
2
|
maintainRelativeOrder: boolean;
|
|
4
3
|
setMaintainRelativeOrder: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,yBACL,OAAO,sBACT,MAAM,SAAS,CAAC,cAAc,CAAC,gBACrC,GAAG,gBACH,GAAG,oBACC,GAAG,EAAE,oBACL,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;CAkFxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GptWebCitation.d.ts","sourceRoot":"","sources":["../../../../../src/features/GptWebCitation/GptWebCitation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAK9D,OAAO,EAAE,oBAAoB,EAA4I,MAAM,SAAS,CAAC;AAmGzL;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"GptWebCitation.d.ts","sourceRoot":"","sources":["../../../../../src/features/GptWebCitation/GptWebCitation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAK9D,OAAO,EAAE,oBAAoB,EAA4I,MAAM,SAAS,CAAC;AAmGzL;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqQlD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export interface CitationData {
|
|
2
|
-
file_id: string;
|
|
3
|
-
phrase_to_highlight: string;
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
6
1
|
export interface SourceAttachment {
|
|
7
2
|
id: string;
|
|
8
3
|
gcsUrl?: string;
|
|
@@ -10,13 +5,7 @@ export interface SourceAttachment {
|
|
|
10
5
|
is_guideline_file?: boolean;
|
|
11
6
|
[key: string]: any;
|
|
12
7
|
}
|
|
13
|
-
export type
|
|
14
|
-
export interface CitationResponse {
|
|
15
|
-
citations?: CitationData[];
|
|
16
|
-
responseData?: {
|
|
17
|
-
citations?: CitationData[];
|
|
18
|
-
};
|
|
19
|
-
}
|
|
8
|
+
export type Guidelines = SourceAttachment[] | Record<string, SourceAttachment[]>;
|
|
20
9
|
export interface SignedUrlResponse {
|
|
21
10
|
responseData?: {
|
|
22
11
|
signed_url?: string;
|
|
@@ -24,8 +13,8 @@ export interface SignedUrlResponse {
|
|
|
24
13
|
signed_url?: string;
|
|
25
14
|
error?: string;
|
|
26
15
|
}
|
|
27
|
-
export declare function
|
|
16
|
+
export declare function isJSONFile(extension?: string): boolean;
|
|
28
17
|
export declare function getSignedUrl(gcsUrl: string, url: string): Promise<SignedUrlResponse>;
|
|
29
|
-
export declare function getFileContent(
|
|
18
|
+
export declare function getFileContent(filePath: string, url: string): Promise<string>;
|
|
30
19
|
export declare function getNestedValue(obj: any, path: string): any;
|
|
31
20
|
//# sourceMappingURL=RuleBookCitationApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBookCitationApi.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationApi.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"RuleBookCitationApi.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationApi.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAClB,gBAAgB,EAAE,GAClB,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAGvC,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,WAE5C;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwB1F;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAC,MAAM,EACf,GAAG,EAAC,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,CAwBjB;AAGD,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAuB1D"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Guidelines } from "./RuleBookCitationApi";
|
|
3
3
|
interface RuleBookCitationWrapperProps {
|
|
4
|
-
|
|
4
|
+
data?: {
|
|
5
|
+
citationNumber: number;
|
|
6
|
+
fileDetails?: {
|
|
7
|
+
file_id: string;
|
|
8
|
+
phrase_to_highlight: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
msg?: any;
|
|
5
12
|
citationIndex?: number;
|
|
6
|
-
|
|
7
|
-
sourceAttachments?: SourceAttachments;
|
|
13
|
+
guidelines?: Guidelines;
|
|
8
14
|
url: string;
|
|
15
|
+
additionalClassNames?: {
|
|
16
|
+
container?: string;
|
|
17
|
+
};
|
|
9
18
|
}
|
|
10
19
|
declare const RuleBookCitationWrapper: React.FC<RuleBookCitationWrapperProps>;
|
|
11
20
|
export default RuleBookCitationWrapper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBookCitationWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RuleBookCitationWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAKL,UAAU,EAEX,MAAM,uBAAuB,CAAC;AAE/B,UAAU,4BAA4B;IACpC,IAAI,CAAC,EAAE;QACL,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE;YACZ,OAAO,EAAE,MAAM,CAAC;YAChB,mBAAmB,EAAE,MAAM,CAAC;SAC7B,CAAC;KACH,CAAC;IACF,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,QAAA,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAqQnE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBookCitationWrapperTest.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationWrapperTest.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RuleBookCitationWrapperTest.d.ts","sourceRoot":"","sources":["../../../../../src/features/RulebookCitations/RuleBookCitationWrapperTest.tsx"],"names":[],"mappings":"AAyHA,QAAA,MAAM,2BAA2B,+CA0KhC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-llm-studio/citation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.221-beta.2",
|
|
4
4
|
"author": "Devesh Patel",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -237,7 +237,6 @@
|
|
|
237
237
|
"@rollup/plugin-url": "^8.0.2",
|
|
238
238
|
"@svgr/rollup": "8.1.0",
|
|
239
239
|
"@types/react": "17.0.83",
|
|
240
|
-
"date-fns": "^4.4.0",
|
|
241
240
|
"@types/react-dom": "17.0.26",
|
|
242
241
|
"@types/react-router-dom": "5.3.3",
|
|
243
242
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
@@ -290,7 +289,8 @@
|
|
|
290
289
|
"rehype-raw": ">=7.0.0",
|
|
291
290
|
"remark-breaks": ">=4.0.0",
|
|
292
291
|
"remark-gfm": ">=4.0.0",
|
|
293
|
-
"wavesurfer.js": "^7.12.1"
|
|
292
|
+
"wavesurfer.js": "^7.12.1",
|
|
293
|
+
"date-fns": "^4.4.0"
|
|
294
294
|
},
|
|
295
295
|
"peerDependenciesMeta": {
|
|
296
296
|
"@mui/icons-material": {
|
|
@@ -349,6 +349,9 @@
|
|
|
349
349
|
},
|
|
350
350
|
"dompurify": {
|
|
351
351
|
"optional": false
|
|
352
|
+
},
|
|
353
|
+
"date-fns": {
|
|
354
|
+
"optional": false
|
|
352
355
|
}
|
|
353
356
|
},
|
|
354
357
|
"dependencies": {
|