PageSourceSearch

https://infoliga.lovable.app/assets/AdminBotTestPage-C0Hur3gZ.js

js infoliga.lovable.app collected 2026-10-03 03:30:29 UTC 5,811 bytes, 1 lines download raw bytes

1import{r as l,j as e,L as v,s as C}from"./index-B8Dc63x_.js";import{A as S}from"./AdminPageLayout-DhX-7Ifi.js";import{B as k}from"./button-9BsRAvlC.js";import{I as B}from"./input-BO6lSX2O.js";import{C as c,b as d,c as o,a as m}from"./card-Dzq9TLgd.js";import{B as b}from"./badge-CmFsG1_o.js";import{S as E}from"./send-B3ivAUUh.js";import{B as R}from"./bug-R9cXPSxs.js";import{E as L}from"./external-link-raBR8Gpg.js";import"./AdminLayout-B7gB7drh.js";import"./users-DDuesyhN.js";import"./megaphone-qcU19r2K.js";import"./video-CaSqQw8D.js";import"./list-todo-ORocy8DV.js";import"./clipboard-list-DB1yZz4I.js";import"./sparkles-DRaIU0gq.js";import"./message-square-DPjWAD2R.js";import"./shield-alert-bCDmMRVx.js";import"./house-CB2G9cqr.js";const T={topic:"bg-green-500/20 text-green-400 border-green-500/30","text-category":"bg-blue-500/20 text-blue-400 border-blue-500/30","text-keyword":"bg-yellow-500/20 text-yellow-400 border-yellow-500/30","text-date":"bg-orange-500/20 text-orange-400 border-orange-500/30",semantic:"bg-purple-500/20 text-purple-400 border-purple-500/30"};function X(){const[a,x]=l.useState(""),[n,p]=l.useState(!1),[t,i]=l.useState(null),[N,u]=l.useState(0),[h,y]=l.useState([]),g=async()=>{if(!a.trim()||n)return;p(!0);const s=Date.now();try{const{data:r,error:j}=await C.functions.invoke("bot-knowledge-search",{body:{query:a.trim(),match_count:5,match_threshold:.4,debug:!0}}),f=Date.now()-s;u(f),j?i({answer:"",materials:[],error:j.message}):(i(r),y(w=>[{query:a.trim(),result:r,elapsed:f},...w.slice(0,19)]))}catch(r){i({answer:"",materials:[],error:r.message})}finally{p(!1)}};return e.jsxs(S,{title:"🤖 Тестирование бота",description:"Отладка поиска по базе знаний для Telegram-бота",children:[e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx(B,{placeholder:"Введите запрос как в Telegram-боте...",value:a,onChange:s=>x(s.target.value),onKeyDown:s=>s.key==="Enter"&&g(),className:"text-base"}),e.jsxs(k,{onClick:g,disabled:n||!a.trim(),children:[n?e.jsx(v,{className:"h-4 w-4 animate-spin"}):e.jsx(E,{className:"h-4 w-4"}),"Поиск"]})]}),t&&e.jsxs("div",{className:"space-y-4",children:[t.debug&&e.jsxs(c,{className:"border-dashed",children:[e.jsx(d,{className:"pb-2",children:e.jsxs(o,{className:"text-sm flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"Отладка (",N,"ms)"]})}),e.jsxs(m,{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Детекция: "}),Object.entries(t.debug.detected).map(([s,r])=>r&&e.jsxs(b,{variant:"outline",className:"mr-1 mb-1",children:[s,": ",r]},s)),Object.values(t.debug.detected).every(s=>!s)&&e.jsx("span",{className:"text-muted-foreground italic",children:"ничего не обнаружено"})]}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs("span",{children:["Topic: ",e.jsx("strong",{children:t.debug.topicResults})]}),e.jsxs("span",{children:["Text: ",e.jsx("strong",{children:t.debug.textResults})]}),e.jsxs("span",{children:["Semantic: ",e.jsx("strong",{children:t.debug.semanticResults})]}),e.jsxs("span",{children:["→ Итого: ",e.jsx("strong",{children:t.debug.totalMerged})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Шаги поиска:"}),e.jsx("ol",{className:"list-decimal list-inside mt-1 space-y-0.5",children:t.debug.searchSteps.map((s,r)=>e.jsx("li",{className:"text-muted-foreground",children:s},r))})]})]})]}),e.jsxs(c,{children:[e.jsx(d,{className:"pb-2",children:e.jsxs(o,{className:"text-sm",children:["Найденные материалы (",t.materials.length,")"]})}),e.jsx(m,{children:t.materials.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Ничего не найдено"}):e.jsx("div",{className:"space-y-2",children:t.materials.map((s,r)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded bg-muted/30 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground font-mono w-5 shrink-0",children:[r+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:s.title}),e.jsx(b,{variant:"outline",className:`text-[10px] ${T[s.source]||""}`,children:s.source}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:[(s.similarity*100).toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-muted-foreground text-xs mt-0.5",children:[s.speaker&&e.jsxs("span",{children:[s.speaker," · "]}),s.category,s.topic?` / ${s.topic}`:"",e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener",className:"ml-2 inline-flex items-center gap-0.5 text-primary hover:underline",children:[e.jsx(L,{className:"h-3 w-3"})," открыть"]})]})]})]},s.id))})})]}),e.jsxs(c,{children:[e.jsx(d,{className:"pb-2",children:e.jsx(o,{className:"text-sm",children:"Ответ AI"})}),e.jsx(m,{children:t.error?e.jsx("p",{className:"text-destructive text-sm",children:t.error}):e.jsx("pre",{className:"whitespace-pre-wrap text-sm font-sans",children:t.answer})})]})]}),h.length>0&&!n&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"История запросов"}),e.jsx("div",{className:"space-y-1",children:h.map((s,r)=>e.jsxs("button",{onClick:()=>{x(s.query),i(s.result),u(s.elapsed)},className:"w-full text-left px-3 py-2 rounded hover:bg-muted/50 text-sm flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:s.query}),e.jsxs("span",{className:"text-muted-foreground text-xs shrink-0 ml-2",children:[s.result.materials.length," рез. · ",s.elapsed,"ms"]})]},r))})]})]})}export{X 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.