@labelbee/lb-components 1.23.0-alpha.130 → 1.23.0-alpha.131
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 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r,{useState as j,useRef as Dt,useMemo as N,useEffect as B}from"react";import{LabelBeeContext as Pt}from"../../../store/ctx.js";import{connect as Ot}from"react-redux";import{prefix as It}from"../../../constant/index.js";import{getStepConfig as Vt}from"../../../store/annotation/reducer.js";import{jsonParser as ut}from"../../../utils/index.js";import Nt,{getSorts as dt}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as Bt}from"react-i18next";import{useCustomToolInstance as $t}from"../../../hooks/annotation.js";import{isBoolean as Wt,isString as Ft,isNumber as kt,isObject as qt,isArray as Gt}from"lodash";import{PageForward as $}from"../../../store/annotation/actionCreators.js";import{cKeyCode as Kt,EToolName as zt}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Ut,EmptyConfig as Qt}from"../../LLMToolView/sidebar/index.js";import Jt from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as ct}from"antd";import Ht from"../../LLMToolView/sidebar/components/answerList/index.js";import Xt from"../../../store/LLMMultiWheel/index.js";import Yt from"../../../utils/StepUtils.js";import{getRenderDataByResult as Zt,getCurrentResultFromResultList as te}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as z}from"ahooks";import ee from"../../LLMToolView/sidebar/components/answerSort/index.js";import ne from"../../tagList/components/overall/index.js";var oe=Object.defineProperty,re=Object.defineProperties,le=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,mt=(c,d,p)=>d in c?oe(c,d,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[d]=p,l=(c,d)=>{for(var p in d||(d={}))ie.call(d,p)&&mt(c,p,d[p]);if(pt)for(var p of pt(d))se.call(d,p)&&mt(c,p,d[p]);return c},u=(c,d)=>re(c,le(d));const ae=Kt.default,ft=`${It}-sidebar`,ue={sort:[],answerSort:{},textAttribute:[],tagList:{}},de=c=>{var d,p,U,Q,J,H;const{annotation:vt,dispatch:A,checkMode:Lt}=c,{imgIndex:y,imgList:W,stepList:M,step:C,skipBeforePageTurning:T}=vt,[m,gt]=j(),{t:R}=Bt(),o=(d=W[y])!=null?d:{},X=ut(o==null?void 0:o.result),{toolInstanceRef:v}=$t({basicInfo:X}),[F,xt]=j(!0),[D,Y]=j({}),[L,Z]=j(ue),k=Dt(),[w,q]=j({}),{selectedID:P,setNewAnswerListMap:tt,newAnswerListMap:et}=Xt(),S=N(()=>D[P],[P,D]),_=!v.current.valid||Lt;B(()=>{var t;if(M&&C){const e=(t=Vt(M,C))==null?void 0:t.config;gt(ut(e))}},[C,JSON.stringify(M)]),B(()=>{!o||y===-1||(v.current.setValid=nt,v.current.clearResult=wt,nt(),ot())},[y,m,o==null?void 0:o.id]);const wt=()=>{var t,e,n,s;ot((t=o==null?void 0:o.questionList)==null?void 0:t.textList),((e=k.current)==null?void 0:e.clearValue)&&((n=k.current)==null||n.clearValue());const{waitSorts:f}=dt({selectedSort:(s=g==null?void 0:g.sort)!=null?s:[],initSelected:[],modelList:h?I!=null?I:[]:[]});q(u(l({},w),{waitSorts:f,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;Wt(n)&&(xt(n),v.current.valid=n,(e=v.current)==null||e.emit("validUpdated"))},St=()=>{const t=Yt.getCurrentStepInfo(C,M);return te(o==null?void 0:o.result,t.step)},g=N(()=>St(),[C,M,o]),ot=z(t=>{var e,n,s,f,a,x;const i=g;let b=(e=o==null?void 0:o.questionList)==null?void 0:e.textList;((n=i==null?void 0:i.modelData)==null?void 0:n.length)&&v.current.valid&&(b=i==null?void 0:i.modelData),t&&(b=t,i.sort=[],i.textAttribute=[],i.answerSort=[]);let V={};b==null||b.forEach((E,At)=>{var at;const Tt=Zt(m,u(l({},E),{answerList:(at=E==null?void 0:E.answerList)==null?void 0:at.map((K,Rt)=>(tt(u(l({},et),{[`${E.id}-${K.id}`]:K.answer})),u(l({},K),{order:Rt+1})))}));V[E.id]=u(l({},Tt),{order:At+1,id:E.id})});const{waitSorts:ht,newSort:jt}=dt({selectedSort:(s=g==null?void 0:g.sort)!=null?s:[],modelList:h?I!=null?I:[]:[]});q({waitSorts:ht,newSort:jt}),Z({sort:(f=i==null?void 0:i.sort)!=null?f:[],textAttribute:(a=i==null?void 0:i.textAttribute)!=null?a:[],answerSort:(x=i==null?void 0:i.answerSort)!=null?x:{},tagList:i==null?void 0:i.tagList}),Y(V)});B(()=>{_t()},[D,F,L]),B(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const _t=z(()=>{var t,e;const n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var a;const x=(a=D[f.id])!=null?a:{};return{id:f.id,answerList:x.answerList}}),s=u(l({},L),{modelData:n});v.current.exportData=()=>[[s],{valid:F}],v.current.currentPageResult=u(l({},s),{toolName:zt.LLMMultiWheel,valid:F})}),rt=t=>{if(t.ctrlKey&&t.keyCode===ae.Enter){if(T){T(()=>A($()));return}A($())}},bt=z(({order:t,value:e,key:n})=>{const{answerList:s}=S,f=s==null?void 0:s.map(a=>{var x,i;if((a==null?void 0:a.order)===t){if(n==="textEdit"&&Ft(e))return tt(u(l({},et),{[`${P}-${(x=a==null?void 0:a.id)!=null?x:""}`]:e})),u(l({},a),{newAnswer:e});if(kt(e))return u(l({},a),{score:e});if(qt(e)&&n){const b={[e==null?void 0:e.key]:e.value},V=(i=a[n])!=null?i:{};return u(l({},a),{[n]:l(l({},V),b)})}}return a});Y(a=>u(l({},a),{[P]:u(l({},S),{answerList:f})}))}),O=(t,e)=>{Z(n=>u(l({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:Et,dialogSort:h=!1,inputList:G=[],tagInputListConfigurable:st,enableSort:yt=!1}=m||{},I=N(()=>{var t,e,n;return h?(n=(e=(t=o==null?void 0:o.questionList)==null?void 0:t.textList)==null?void 0:e.map((s,f)=>u(l({},s),{title:f+1})))!=null?n:[]:[]},[o,h]);if(N(()=>Ut(m),[m]))return r.createElement(Qt,null);const Mt=st&&((p=G.filter(t=>!t.isOverall))==null?void 0:p.length)>0,Ct=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||Et||Mt;return r.createElement("div",{className:`${ft}`},r.createElement("div",{className:`${ft}__content`},r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},R("GlobalAnnotation")),h&&r.createElement(ee,{waitSortList:(w==null?void 0:w.waitSorts)||[],sortList:(w==null?void 0:w.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(s=>s.id));O("sort",e),q(u(l({},w),{newSort:t}))},disabeledAll:_,title:R("SortConversationQuality"),prefixId:"model"}),(m==null?void 0:m.text)&&r.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},r.createElement(Jt,{textAttribute:(U=L==null?void 0:L.textAttribute)!=null?U:[],textConfig:(m==null?void 0:m.text)&&Gt(m.text)?m==null?void 0:m.text:[],setText:t=>O("textAttribute",t),disabeledAll:_})),yt&&r.createElement(Nt,{modelData:(J=(Q=o==null?void 0:o.questionList)==null?void 0:Q.textList)!=null?J:[],selectedAnswerSort:t=>O("answerSort",t),selectedSort:(H=g==null?void 0:g.answerSort)!=null?H:[],ref:k,disabeledAll:_,imgIndex:y}),st&&G.length&&r.createElement(ne,{inputList:G,selectedTags:(L==null?void 0:L.tagList)||{},updateValue:t=>{const{key:e,value:n}=t,s=(L==null?void 0:L.tagList)||{};O("tagList",u(l({},s),{[e]:n}))},disabeledAll:_}),S&&r.createElement(r.Fragment,null,r.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},R("QualifiedAnnotation")),r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},r.createElement(ct,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),r.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",S.order)),r.createElement("div",null,Ct&&r.createElement(Ht,{list:(S==null?void 0:S.answerList)||[],LLMConfig:m,updateValue:bt,disabeledAll:_})))),r.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(W==null?void 0:W.length)-1!==y&&r.createElement(ct,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(T){T(()=>A($()));return}A($())},disabled:_},R("Save"))))},ce=c=>({annotation:c.annotation});var pe=Ot(ce,null,null,{context:Pt})(de);export{pe as default};
|