2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
var g=(b,y,c)=>new Promise((p,d)=>{var t=i=>{try{f(c.next(i))}catch(l){d(l)}},h=i=>{try{f(c.throw(i))}catch(l){d(l)}},f=i=>i.done?p(i.value):Promise.resolve(i.value).then(t,h);f((c=c.apply(b,y)).next())});import{ae as B,V as N,a9 as _,au as w,bS as E,bU as k,ay as K,bE as T,an as C}from"./bootstrap-CRjSNGHY.js";import{b as U}from"./index-CDx2929e.js";import{a as V}from"./index-Cjo5Wm4a.js";import{_ as q}from"./page.vue_vue_type_script_setup_true_lang-3ywDTU7g.js";import{m as D,b9 as j,b7 as S,v as z,ab as L,b2 as m,bJ as v,ae as e,j as o,u as n,bp as r,ai as I,ad as x,I as R,bb as $,aR as F}from"../jse/index-index-CMeVxoEG.js";const J={class:"flex w-full gap-4"},M={class:"relative m-2"},P={class:"absolute bottom-2 right-2 text-sm text-gray-400"},A={class:"m-2 flex items-center"},G={class:"m-2 flex items-center"},H={class:"flex justify-end"},O={key:0,class:"flex h-72 items-center justify-center"},Q={class:"mb-15 font-bold"},W={class:"mb-2 flex items-center justify-between gap-8 text-sm text-gray-500"},X={class:"whitespace-nowrap rounded-full bg-blue-50 px-2 py-1 text-sm text-blue-500"},Y={class:"flex items-center justify-between gap-8"},Z={class:"flex items-center gap-1 text-sm text-gray-500"},ee={key:2,class:"flex h-72 items-center justify-center"},re=D({name:"KnowledgeDocumentRetrieval",__name:"index",setup(b){const y=B(),c=N(),p=j(!1),d=j([]),t=S({id:void 0,content:"",topK:10,similarityThreshold:.5});function h(){return g(this,null,function*(){if(!t.content){_.warning("请输入查询文本");return}p.value=!0,d.value=[];try{const l=yield V({knowledgeId:t.id,content:t.content,topK:t.topK,similarityThreshold:t.similarityThreshold});d.value=l||[]}finally{p.value=!1}})}function f(l){l.expanded=!l.expanded}function i(l){return g(this,null,function*(){try{const s=yield U(l);s&&(t.topK=s.topK||t.topK,t.similarityThreshold=s.similarityThreshold||t.similarityThreshold)}catch(s){}})}return z(()=>{if(!y.query.id){_.error("知识库 ID 不存在,无法进行召回测试"),c.back();return}t.id=y.query.id,i(t.id)}),(l,s)=>(m(),L(n(q),{"auto-content-height":""},{default:v(()=>[e("div",J,[o(n(w),{class:"w-3/4 flex-1"},{default:v(()=>{var a;return[s[6]||(s[6]=e("div",{class:"mb-15"},[e("h3",{class:"m-2 text-lg font-semibold leading-none tracking-tight"}," 召回测试 "),e("div",{class:"m-2 text-sm text-gray-500"}," 根据给定的查询文本测试召回效果。 ")],-1)),e("div",null,[e("div",M,[o(n(E),{value:t.content,"onUpdate:value":s[0]||(s[0]=u=>t.content=u),rows:8,placeholder:"请输入文本"},null,8,["value"]),e("div",P,r((a=t.content)==null?void 0:a.length)+" / 200 ",1)]),e("div",A,[s[3]||(s[3]=e("span",{class:"w-16 text-gray-500"},"topK:",-1)),o(n(k),{value:t.topK,"onUpdate:value":s[1]||(s[1]=u=>t.topK=u),min:1,max:20,class:"w-full"},null,8,["value"])]),e("div",G,[s[4]||(s[4]=e("span",{class:"w-16 text-gray-500"},"相似度:",-1)),o(n(k),{value:t.similarityThreshold,"onUpdate:value":s[2]||(s[2]=u=>t.similarityThreshold=u),class:"w-full",min:0,max:1,precision:2,step:.01},null,8,["value"])]),e("div",H,[o(n(K),{type:"primary",onClick:h,loading:p.value},{default:v(()=>[...s[5]||(s[5]=[I(" 测试 ",-1)])]),_:1},8,["loading"])])])]}),_:1}),o(n(w),{class:"min-w-300 flex-1"},{default:v(()=>[p.value?(m(),x("div",O,[o(n(T),{description:"正在检索中..."})])):d.value.length>0?(m(),x(R,{key:1},[e("div",Q,r(d.value.length)+" 个召回段落",1),e("div",null,[(m(!0),x(R,null,$(d.value,(a,u)=>(m(),x("div",{key:u,class:"mt-2 rounded border border-solid border-gray-200 px-2 py-2"},[e("div",W,[e("span",null," 分段("+r(a.id)+") · "+r(a.contentLength)+" 字符数 · "+r(a.tokens)+" Token ",1),e("span",X," score: "+r(a.score),1)]),e("div",{class:F(["mb-2 overflow-hidden whitespace-pre-wrap rounded bg-gray-50 text-sm transition-all duration-100",{"line-clamp-2 max-h-40":!a.expanded,"max-h-[1500px]":a.expanded}])},r(a.content),3),e("div",Y,[e("div",Z,[o(n(C),{icon:"lucide:file-text"}),e("span",null,r(a.documentName||"未知文档"),1)]),o(n(K),{size:"small",onClick:te=>f(a)},{default:v(()=>[I(r(a.expanded?"收起":"展开")+" ",1),o(n(C),{icon:a.expanded?"lucide:chevron-up":"lucide:chevron-down"},null,8,["icon"])]),_:2},1032,["onClick"])])]))),128))])],64)):(m(),x("div",ee,[o(n(T),{description:"暂无召回结果"})]))]),_:1})])]),_:1}))}});export{re as default};
|