PageSourceSearch

https://legalaios2.manus.space/assets/RagTest-73AQcWh_.js

js legalaios2.manus.space collected 2026-10-03 05:03:20 UTC 8,668 bytes, 1 lines download raw bytes

1import{r as o,j as e}from"./vendor-react-D_PmJq1g.js";import{A as w}from"./AIChatBox-Bb2o1bcB.js";import{C as k,E as A,S as u,a as R,b as j,c as T,d as m}from"./ConsolePage-hLYCyqMG.js";import{B as b}from"./badge-DKUuEzvb.js";import{v as E,n as I,p as M,B}from"./index-CH-dzzKG.js";import{C as f,b as z,c as P,a as N}from"./card-7Q-CsnHA.js";import{w as _,x as L,y as V,S as $,h as F}from"./vendor-ui-CX5AecA-.js";import"./vendor-streamdown-DfOLai02.js";import"./marked.esm-Dsh_Zqam.js";import"./vendor-markdown-remark-DZ02DjD2.js";import"./vendor-markdown-micromark-CZ2gdOlH.js";import"./vendor-markdown-rehype-BIav0voV.js";import"./vendor-data-tjINLo7H.js";function ee(){const{activeSiteId:r,summary:v}=E(),c=v?.agents??[],[t,d]=o.useState(null),[n,S]=o.useState("draft"),[p,i]=o.useState([]),[a,g]=o.useState(null);o.useEffect(()=>{if(!c.length){d(null);return}(!t||!c.some(s=>s.id===t))&&d(c[0].id)},[t,c]),o.useEffect(()=>{i([]),g(null)},[r,t,n]);const h=I.ai.ragTest.useMutation({onSuccess:s=>{i(l=>[...l,{role:"assistant",content:s.answer}]),g({model:s.model,sources:s.sources,usage:s.usage})},onError:s=>M.error(s.message)});function y(s){if(!r||!t)return;const l=[...p,{role:"user",content:s}];i(l),h.mutate({siteId:r,agentId:t,mode:n,turns:l.map(x=>({role:x.role==="system"?"user":x.role,content:x.content}))})}function C(){i([]),g(null)}return e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:72",children:[e.jsx(k,{"data-loc":"client/src/pages/console/RagTest.tsx:73",eyebrow:"Quality Lab",title:"RAG 測試",description:"在發布前,用真實問題檢查知識命中、回答邊界與引用品質。草稿模式讀取目前編輯內容;正式模式只讀取已發布版本。",action:e.jsxs(B,{"data-loc":"client/src/pages/console/RagTest.tsx:78",variant:"outline",className:"border-slate-200 bg-white text-slate-800 hover:bg-slate-50",onClick:C,children:[e.jsx(_,{"data-loc":"client/src/pages/console/RagTest.tsx:79",className:"size-4"}),"重新測試"]})}),!r||c.length===0?e.jsx(A,{"data-loc":"client/src/pages/console/RagTest.tsx:85",icon:e.jsx(L,{"data-loc":"client/src/pages/console/RagTest.tsx:86",className:"size-5"}),title:"尚無可測試的 Agent",description:"請先在多網站管理建立 Agent,再回到這裡驗證知識庫回答品質。"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:92",className:"mb-5 grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-4 md:grid-cols-[1fr_1fr_auto] md:items-end",children:[e.jsxs("label",{"data-loc":"client/src/pages/console/RagTest.tsx:93",className:"space-y-2 text-xs font-semibold text-slate-600",children:["測試 Agent",e.jsxs(u,{"data-loc":"client/src/pages/console/RagTest.tsx:95",value:t?String(t):void 0,onValueChange:s=>d(Number(s)),children:[e.jsx(R,{"data-loc":"client/src/pages/console/RagTest.tsx:96",className:"border-slate-200 bg-white text-navy-950",children:e.jsx(j,{"data-loc":"client/src/pages/console/RagTest.tsx:97",placeholder:"選擇 Agent"})}),e.jsx(T,{"data-loc":"client/src/pages/console/RagTest.tsx:99",children:c.map(s=>e.jsxs(m,{"data-loc":"client/src/pages/console/RagTest.tsx:101",value:String(s.id),children:[s.name," · ",s.model]},s.id))})]})]}),e.jsxs("label",{"data-loc":"client/src/pages/console/RagTest.tsx:106",className:"space-y-2 text-xs font-semibold text-slate-600",children:["知識版本",e.jsxs(u,{"data-loc":"client/src/pages/console/RagTest.tsx:108",value:n,onValueChange:s=>S(s),children:[e.jsx(R,{"data-loc":"client/src/pages/console/RagTest.tsx:109",className:"border-slate-200 bg-white text-navy-950",children:e.jsx(j,{"data-loc":"client/src/pages/console/RagTest.tsx:110"})}),e.jsxs(T,{"data-loc":"client/src/pages/console/RagTest.tsx:112",children:[e.jsx(m,{"data-loc":"client/src/pages/console/RagTest.tsx:113",value:"draft",children:"草稿內容(發布前測試)"}),e.jsx(m,{"data-loc":"client/src/pages/console/RagTest.tsx:114",value:"published",children:"正式發布內容"})]})]})]}),e.jsx(b,{"data-loc":"client/src/pages/console/RagTest.tsx:118",variant:"outline",className:`h-10 justify-center rounded-xl px-4 ${n==="draft"?"border-amber-300/20 text-amber-200":"border-emerald-300/20 text-emerald-800"}`,children:n==="draft"?"草稿沙盒":"正式知識"})]}),e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:123",className:"grid gap-5 xl:grid-cols-[minmax(0,1.55fr)_minmax(310px,0.75fr)]",children:[e.jsx(w,{"data-loc":"client/src/pages/console/RagTest.tsx:124",messages:p,onSendMessage:y,isLoading:h.isPending,height:"min(680px, calc(100vh - 260px))",className:"min-h-[560px] overflow-hidden rounded-[1.4rem] border-champagne-400/12 bg-white shadow-2xl shadow-black/20",placeholder:"輸入真實問題,檢查 RAG 回答…",emptyStateMessage:"用一個真實法律或品牌問題開å
1§‹å“è³ªæ¸¬è©¦",suggestedPrompts:["如果知識不足,你會如何處理?","請根據目前知識說明服務範圍與限制。","哪些情況應該轉由真人律師確認?"]}),e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:139",className:"space-y-4",children:[e.jsxs(f,{"data-loc":"client/src/pages/console/RagTest.tsx:140",className:"border-slate-200 bg-slate-50",children:[e.jsx(z,{"data-loc":"client/src/pages/console/RagTest.tsx:141",className:"pb-3",children:e.jsxs(P,{"data-loc":"client/src/pages/console/RagTest.tsx:142",className:"flex items-center gap-2 text-base text-navy-950",children:[e.jsx(V,{"data-loc":"client/src/pages/console/RagTest.tsx:143",className:"size-4 text-champagne-700"}),"知識命中"]})}),e.jsx(N,{"data-loc":"client/src/pages/console/RagTest.tsx:146",className:"space-y-3",children:a?a.sources.length===0?e.jsx("div",{"data-loc":"client/src/pages/console/RagTest.tsx:150",className:"rounded-xl border border-amber-300/12 bg-amber-300/5 p-3 text-sm leading-6 text-amber-100/80",children:"沒有命中知識片段。此回答應明確標示需要查證,而非補造品牌規則或裁判資料。"}):a.sources.map((s,l)=>e.jsxs("details",{"data-loc":"client/src/pages/console/RagTest.tsx:155",className:"group rounded-xl border border-slate-200 bg-white p-3 open:border-champagne-400/18",children:[e.jsxs("summary",{"data-loc":"client/src/pages/console/RagTest.tsx:156",className:"cursor-pointer list-none text-sm font-semibold text-slate-800",children:[e.jsxs("span",{"data-loc":"client/src/pages/console/RagTest.tsx:157",className:"text-champagne-700",children:["[",l+1,"]"]})," ",s.title,e.jsxs("span",{"data-loc":"client/src/pages/console/RagTest.tsx:158",className:"ml-2 text-[0.68rem] font-normal text-slate-500",children:["v",s.versionNumber," · ",s.score," 分"]})]}),e.jsx("p",{"data-loc":"client/src/pages/console/RagTest.tsx:160",className:"mt-3 max-h-44 overflow-auto whitespace-pre-wrap text-xs leading-6 text-slate-600",children:s.excerpt})]},`${s.documentId}-${l}`)):e.jsx("p",{"data-loc":"client/src/pages/console/RagTest.tsx:148",className:"text-sm leading-6 text-slate-500",children:"送出問題後,這裡會顯示提供給模型的知識片段與版本。"})})]}),e.jsx(f,{"data-loc":"client/src/pages/console/RagTest.tsx:167",className:"border-slate-200 bg-slate-50",children:e.jsxs(N,{"data-loc":"client/src/pages/console/RagTest.tsx:168",className:"space-y-3 p-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:169",className:"flex items-center gap-2 text-sm font-semibold text-navy-950",children:[e.jsx($,{"data-loc":"client/src/pages/console/RagTest.tsx:170",className:"size-4 text-emerald-700"}),"安全檢查基準"]}),e.jsxs("ul",{"data-loc":"client/src/pages/console/RagTest.tsx:172",className:"space-y-2 text-xs leading-5 text-slate-600",children:[e.jsx("li",{"data-loc":"client/src/pages/console/RagTest.tsx:173",children:"不得虛構法條、裁判字號或知識庫內容。"}),e.jsx("li",{"data-loc":"client/src/pages/console/RagTest.tsx:174",children:"涉及時效、訴訟或重大權益時應建議律師覆核。"}),e.jsx("li",{"data-loc":"client/src/pages/console/RagTest.tsx:175",children:"回答結尾須標示一般法律資訊免責聲明。"})]})]})}),a&&e.jsxs("div",{"data-loc":"client/src/pages/console/RagTest.tsx:181",className:"flex flex-wrap items-center gap-2 text-[0.68rem] text-slate-500",children:[e.jsxs(b,{"data-loc":"client/src/pages/console/RagTest.tsx:182",variant:"outline",className:"border-slate-200 text-slate-600",children:[e.jsx(F,{"data-loc":"client/src/pages/console/RagTest.tsx:182",className:"mr-1 size-3"}),a.model]}),a.usage&&e.jsxs("span",{"data-loc":"client/src/pages/console/RagTest.tsx:183",children:[a.usage.total_tokens.toLocaleString()," tokens"]})]})]})]})]})]})}export{ee as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.