filecat 6.15.2 → 6.16.0
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/build/dist/1448.39d5d8413bf99259a876.js +1 -0
- package/build/dist/{1595.fba7940cddb86cb069ad.js → 1595.5f5ec6122acae3a9cd0b.js} +1 -1
- package/build/dist/{6413.50f7e1816f783cb0ac81.js → 6413.78acefe251849e167bbb.js} +1 -1
- package/build/dist/8302.5e452d01292ba0adf3e7.js +1 -0
- package/build/dist/9782.fff8cd19583e0dfbb81d.js +1 -0
- package/build/dist/index.html +1 -1
- package/build/dist/{main.f9943c1e5a8a677b0bf9.js → main.233d56b27b9ff0c45ce3.js} +2 -2
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/1448.cb0b816ecce11857fbc4.js +0 -1
- package/build/dist/8302.19a72820071ef3c3e981.js +0 -1
- package/build/dist/9782.8d3c7e34aa48c5897da7.js +0 -1
- /package/build/dist/{main.f9943c1e5a8a677b0bf9.js.LICENSE.txt → main.233d56b27b9ff0c45ce3.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1448],{83277(e,t,s){s.d(t,{$j:()=>r,Lv:()=>i,qq:()=>n});class l{options_agent_url_list;options_agent_key_list;options_agent_model_list}class i{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const s of t)if(s.value===e)return s.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const s of t)if(s.value===e)return!0;return!1}}class n extends l{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url}const a=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function r(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}s.d(t,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n',"cL",0,a])},11448(e,t,s){s.r(t),s.d(t,{RebotCardContainer:()=>f,default:()=>y});var l=s(22022),i=s(96540),n=s(85997),a=s(57952),r=s(75725),o=s(61443),c=s(70447),d=s(14284),_=s(53459),h=s(62042),x=s(78247),p=s(23430),m=s(61973),j=(s(83277),s(92350)),u=s(74848);const b={qq:{key:"qq",label:"QQ 机器人",icon:"QQ",color:"#12B7F5",fields:[{key:"appId",label:"AppId",type:"text",placeholder:"请输入机器人 AppId",required:!0},{key:"clientSecret",label:"密钥",type:"password",placeholder:"请输入机器人密钥",required:!0}]}},g=Object.entries(b).map(([e,t])=>({value:e,title:t.label,color:t.color}));function f(e){const{t}=(0,l.Bd)(),[s,a]=(0,i.useState)(!1),[r,c]=(0,i.useState)(!1),d=(t,s)=>{const l=[...e.items];l[t]={...l[t],...s},e.setItems(l)},_=t=>{const s=[...e.items];s.splice(t,1),e.setItems(s)},h=t=>{e.setItems([...e.items,{...e.items[t],open:!1,name:(e.items[t].name||"")+" (副本)"}])};return(0,u.jsxs)(i.Fragment,{children:[(0,u.jsx)("div",{className:"airebot-setting__toolbar",children:!1!==e.have_auth_edit&&(0,u.jsxs)(u.Fragment,{children:[s?(0,u.jsxs)("div",{className:"airebot-setting__add-select",children:[(0,u.jsx)(o.l6,{options:g,defaultValue:"qq",onChange:t=>{return s=t,e.setItems([...e.items,{platform:s,name:"",open:!1,appId:"",clientSecret:"",note:""}]),void a(!1);var s},width:"180px"}),(0,u.jsx)(n.rA,{icon:"cancel",title:t("取消"),onClick:()=>a(!1)})]}):(0,u.jsx)(n.rA,{icon:"add",title:t("添加机器人"),onClick:()=>a(!0)}),(0,u.jsx)(n.rA,{icon:"save",title:t(r?"保存中...":"保存"),onClick:()=>{r||(async()=>{c(!0),await e.save(),c(!1)})()}})]})}),0===e.items.length?(0,u.jsxs)("div",{className:"airebot-setting__empty",children:[(0,u.jsx)("span",{className:"material-symbols-outlined airebot-setting__empty-icon",children:"smart_toy"}),(0,u.jsx)("p",{children:t("还没有配置任何机器人")}),(0,u.jsx)("p",{className:"airebot-setting__empty-hint",children:t("点击上方「添加机器人」按钮来开始配置")})]}):(0,u.jsx)("div",{className:"airebot-setting__grid",children:e.items.map((e,t)=>(0,u.jsx)(v,{item:e,index:t,onChange:d,onDelete:_,onCopy:h},t))})]})}const v=({item:e,index:t,onChange:s,onDelete:i,onCopy:a})=>{const{t:r}=(0,l.Bd)(),d=b[e.platform]??b.qq,_=e._status||"disconnected";e.open;return(0,u.jsx)(c.Zp,{self_title:(0,u.jsx)("div",{className:"airebot-setting__card-header",children:(0,u.jsx)("span",{className:"material-symbols-outlined airebot-setting__card-icon",style:{color:d.color},children:d.icon})}),titleCom:(0,u.jsxs)("div",{className:"airebot-setting__card-actions",children:[(0,u.jsx)(n.Ay,{checked:!!e.open,onChange:e=>s(t,{open:e})}),(0,u.jsx)(n.rA,{icon:"content_copy",title:r("复制"),onClick:()=>a(t)}),(0,u.jsx)(n.rA,{icon:"delete",title:r("删除"),onClick:()=>i(t)})]}),children:(0,u.jsxs)("div",{className:"airebot-setting__card-fields",children:[(0,u.jsxs)("div",{className:"airebot-setting__field",children:[(0,u.jsx)("label",{className:"airebot-setting__field-label",children:r("平台")}),(0,u.jsx)(o.l6,{options:g,value:e.platform,onChange:e=>s(t,{platform:e}),width:"100%"})]}),(0,u.jsxs)("div",{className:"airebot-setting__field",children:[(0,u.jsx)("label",{className:"airebot-setting__field-label",children:r("名称")}),(0,u.jsx)(o.Sm,{value:e.name||"",handleInputChange:e=>s(t,{name:e}),placeholder:r("给机器人起个名字")})]}),d.fields.map(l=>{const i=e[l.key]??"";return(0,u.jsxs)("div",{className:"airebot-setting__field",children:[(0,u.jsxs)("label",{className:"airebot-setting__field-label",children:[l.label,l.required&&(0,u.jsx)("span",{className:"airebot-setting__field-required",children:"*"})]}),(0,u.jsx)(o.Sm,{type:l.type,value:i,handleInputChange:e=>s(t,{[l.key]:e}),placeholder:l.placeholder})]},l.key)}),(0,u.jsxs)("div",{className:"airebot-setting__field ",children:[(0,u.jsx)("label",{className:"airebot-setting__field-label",children:r("模型编号")}),(0,u.jsx)(o.Sm,{value:e.model_index,handleInputChange:e=>s(t,{model_index:e}),placeholder:r("使用指定模型(可选)")})]}),(0,u.jsxs)("div",{className:"airebot-setting__field ",children:[(0,u.jsx)("label",{className:"airebot-setting__field-label",children:r("用户id")}),(0,u.jsx)(o.Sm,{value:e.user_id||"",handleInputChange:e=>s(t,{user_id:e}),placeholder:r("默认使用root账户(继承权限,可选)")})]}),(0,u.jsxs)("div",{className:"airebot-setting__field airebot-setting__field-full",children:[(0,u.jsx)("label",{className:"airebot-setting__field-label",children:r("备注")}),(0,u.jsx)(o.Sm,{value:e.note||"",handleInputChange:e=>s(t,{note:e}),placeholder:r("备注信息(可选)")})]})]})})};function y(){const{t:e}=(0,l.Bd)(),t=(0,m.Zp)(),{check_user_auth:s}=(0,x.MH)(),[o,c]=(0,i.useState)([]),b=(0,j.Q)(),g=async()=>{const e=await d.XO.get("ai_rebot_setting");e.code===_.m.Success&&c(e.data?.list??[])};(0,i.useEffect)(()=>{g()},[]);return(0,u.jsxs)("div",{className:"airebot-setting",children:[(0,u.jsx)(a.A,{children:s(p.oV.ai_agent_setting)&&(0,u.jsx)(n.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>t(-1)})}),(0,u.jsx)(r.fI,{children:(0,u.jsxs)(r.VP,{widthPer:100,children:[(0,u.jsxs)("div",{className:"airebot-setting__page-title",children:[(0,u.jsx)("h2",{children:e("机器人配置")}),(0,u.jsx)(n.rA,{icon:"info",onClick:()=>{b("机器人配置")},title:"信息"})]}),(0,u.jsx)(f,{items:o,setItems:c,save:async()=>{const t={list:o.map((e,t)=>({...e,index:t}))};(await d.XO.post("ai_rebot_setting/save",t)).code===_.m.Success&&((0,h.SK)(e("保存成功")),await g())},have_auth_edit:s(p.oV.ai_agent_setting)})]})})]})}s.d(t,["PLATFORM_META",0,b,"RebotCard",0,v])},92350(e,t,s){s.d(t,{Q:()=>_,o:()=>x});var l=s(34843),i=s(82893),n=s(74777),a=s(96540),r=s(22022),o=s(23430),c=s(14284),d=s(74848);function _(){const[e,t]=(0,l.fp)(i.AG.prompt_card),{t:s,i18n:a}=(0,r.Bd)();return e=>{let l;e===n.jk.ffmpeg?l=(0,d.jsx)("div",{children:"视频转换,rtsp播放器等媒体功能都需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置"}):e===n.jk.smartmontools?l=(0,d.jsx)("div",{children:"磁盘检查需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置。"}):"保护目录"===e?l=(0,d.jsxs)("div",{children:["在删除的时候保护目录会拒绝删除。",(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"可以使用 /* 来表达该目录下所有文件都禁止删除"}),(0,d.jsx)("li",{children:"可以使用 /** 来表达该目录下所有子目录文件都禁止删除"})]})]}):"文件夹路径"===e?l=(0,d.jsx)("div",{children:"用于在文件夹下切换根目录"}):"环境路径"===e?l=(0,d.jsx)("div",{children:"当在不同用户环境下运行的时候由于没有执行终端去加载PATH,这里可以添加额外的PATH路径,点击这里的保存还会更新系统上的path路径"}):"pty"===e?l=(0,d.jsx)("div",{children:"一些需要Pty环境的命令"}):"文件上传"===e?l=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"对于不同的目录(包括所有子目录),可能是机械或者固态硬盘,机械硬盘在处理多个小文件的时候会做随机i/o,由于一般只有一个盘头所以会影响整体效率,特别是写操作,这里提供了上传时候的最大数量限制,对于下载数量目前不做限制."}),(0,d.jsx)("li",{children:"大文件支持断点和分块并发传输,建议并发数量设置为2,分块大小设置为10MB,大文件判断为500MB,设置过大的话会上传的时候会占据较大内存"})]})}):"目录快捷命令"===e?l=(0,d.jsx)("div",{children:"右键文件夹空白处用于,打开终端快捷执行命令"}):"文件快捷命令"===e?l=(0,d.jsx)("div",{children:"用于右键特定后缀的文件,执行一些快捷命令,文件后缀可以是多个,用空格分割"}):"Workflow"===e?l=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"在特定的时间启动系统中的workflow任务"}),(0,d.jsx)("li",{children:"cron表达式是定时器 格式为: 秒 分 时 日 月 星期"}),(0,d.jsxs)("li",{children:[(0,d.jsx)("li",{children:'1. "*"(通配符,所有值)'}),(0,d.jsx)("li",{children:'2. "," 是枚举: 0 0 1,15 * * *'}),(0,d.jsx)("li",{children:'3. "-" 是范围: 0 0 1-5 * * *'}),(0,d.jsx)("li",{children:'4. "/" 是步长,标识每隔n执行 */3 * * * * * 每隔三秒,必须配合 * 使用 ,/ 只能写一次 ,有了/就成了定时器,而不是指定时间执行'})]})]})}):"插件配置"===e?l=(0,d.jsx)("div",{children:s("路径可以是一个 js 文件也可以是一个node 项目目录")}):"机器人配置"===e&&(l=(0,d.jsxs)("div",{children:[(0,d.jsx)("dv",{children:"机器人功能用于开通各种第三方支持的机器人,让第三方机器人接入本地的 AI 模型。"}),(0,d.jsx)("ul",{children:(0,d.jsx)("li",{children:" 1. qq 机器人需要先在手机 app 中添加,然后在https://q.qq.com/qqbot/ 登录机器人配置页面,在开发管理中复制机器人的 appId,appSecret 到这里就完成了配置了。"})})]})),t({open:!0,title:"信息",context_div:(0,d.jsx)("div",{children:l})})}}let h=o.Ky;function x(){const[e,t]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{try{const e=await c.XO.get("themes");if(0===e.code){const s=e.data||[];h=[...o.Ky,...s],t(h)}else console.warn("获取主题列表失败,使用默认列表"),t(h)}catch(e){t(h)}})()},[]),e}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8302],{83277(e,t,n){n.d(t,{$j:()=>a,Lv:()=>o,qq:()=>i});class s{options_agent_url_list;options_agent_key_list;options_agent_model_list}class o{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const n of t)if(n.value===e)return n.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const n of t)if(n.value===e)return!0;return!1}}class i extends s{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url}const l=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function a(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}n.d(t,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n',"cL",0,l])},77481(e,t,n){n.d(t,{S:()=>l,X:()=>i});var s=n(96540),o=n(74848);function i(e){const[t,n]=s.useState([]);return(0,s.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]),(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((e,t)=>(0,o.jsx)("th",{children:e},t))})}),(0,o.jsx)("tbody",{children:t.map((t,n)=>(0,o.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},children:t.map((n,s)=>(0,o.jsx)("td",{style:{width:e.width??"auto"},className:s===t.length-1?"small":"",children:n},s))},n))})]})}function l(e){return(0,o.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,o.jsx)("div",{children:e},t))})}},29591(e,t,n){n.r(t),n.d(t,{default:()=>K});var s=n(22022),o=n(96540),i=n(85997),l=n(57952),a=n(34843),r=n(82893),c=n(75725),d=n(77481),p=n(61443),u=n(70447),h=n(34299),_=n(74848);var m=n(14284),x=n(53459),j=n(62042),v=n(7523),g=n(78247),f=n(23430),w=n(61973),y=n(14944),C=n(92275),k=n(88815),b=n(45907),A=n(12721),S=n(24659),I=n(83277),$=n(96494);function K(){const{t:e}=(0,s.Bd)(),{initUserInfo:t}=(0,o.useContext)(v.F),n=[e("编号"),e("url"),e("model类型"),e("是否开启"),e("key"),"model",e("成为tool"),e("更多属性"),e("备注")],K=(0,$.r)(),N=[e("编号"),e("本地目录"),e("自动加载"),e("备注")],[P,M]=(0,o.useState)([]),[O,X]=(0,o.useState)([]),[V,L]=(0,o.useState)([]),[H,F]=(0,o.useState)(null),Y=(0,o.useRef)(),q=(0,o.useRef)(!1),G=(0,o.useRef)(!1),[z,B]=(0,o.useState)([]),[R,T]=(0,o.useState)(!1),[D,E]=(0,a.fp)(r.AG.prompt_card),[J,Z]=(0,a.fp)(r.AG.user_base_info),[U,W]=(0,o.useState)(!1),Q=V.filter(e=>"http"!==(e.transport??"stdio")),ee=V.filter(e=>"http"===e.transport),te=[e("编号"),e("名称"),e("是否开启"),"command","args","cwd",e("tools|env"),e("备注")],ne=[e("编号"),e("名称"),e("是否开启"),e("endpoint"),e("tools|headers"),e("备注")],se=[e("编号"),e("提示词"),e("备注")],[oe,ie]=(0,o.useState)([]),le=function(){const[e,t]=(0,a.fp)(r.AG.prompt_card);return e=>{t({open:!0,title:"信息",context_div:(0,_.jsx)("div",{children:(0,_.jsx)(h.default,{context:e})})})}}(),{check_user_auth:ae}=(0,g.MH)(),[re,ce]=(0,a.fp)(r.AG.editorSetting),de=(0,w.Zp)(),pe=(0,b.y)(),ue=(0,S.K)(),he=async()=>{const e=await m.jV.get("docs_on_get");e.code===x.m.Success&&W(e.data)};(0,o.useEffect)(()=>{(async()=>{const e=await m.XO.get("ai_agent_setting");e.code===x.m.Success&&M(e.data.models),await y.ws.addMsg(C.HK.ai_load_info,e=>{F(e.context)});const t=await y.ws.sendData(C.HK.ai_load_info,{});t?.context&&F(t.context);const n=await m.XO.get("ai_docs_setting");n.code===x.m.Success&&(Y.current=n.data.param,n.data.list?.length&&X(n.data.list));const s=await m.XO.get("ai_mcp_setting");s.code===x.m.Success&&L(s.data.list??[]),await ge(),he();const o=await m.XO.get("ai_system_prompts");o.code===x.m.Success&&ie(o.data??[])})()},[]);const _e=(e="stdio")=>{const t="http"===e?{name:"",open:!1,note:"",transport:"http",endpoint:"",headers:"",stream:!1,timeout_ms:1e4}:{name:"",open:!1,command:"",args:"",cwd:"",env:"",note:"",transport:"stdio",timeout_ms:1e4};L([...V,t]),q.current=!0},me=e=>{const t=V.indexOf(e);t<0||(V.splice(t,1),L([...V]),q.current=!0)},xe=e=>{L([...V,{...e,open:!1}]),q.current=!0},je=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;(await m.XO.post("ai_agent_setting/save",{models:e??P})).code===x.m.Success&&(0,j.SK)("保存成功")},ve=async e=>{for(let e=0;e<V.length;e++)V[e].index=e;(await m.XO.post("ai_mcp_setting/save",{list:e??V})).code===x.m.Success&&((0,j.SK)("保存成功"),q.current=!1,await ge())},ge=async()=>{const e=await m.XO.get("ai_mcp_tools");return e.code===x.m.Success?(B(e.data??[]),e.data??[]):[]},fe=async e=>{T(!0);try{const t=await m.XO.post("ai_mcp_tools/reload",{index:e});if(t.code===x.m.Success)return await ge(),(0,j.SK)("MCP工具加载成功"),t.data??null}finally{T(!1)}return null},we=async(t,n,s,o)=>{const i=o??z.find(e=>e.index===n)??{index:n,key:`${n}`,name:t.name??"",note:t.note,transport:t.transport??"stdio",open:!!t.open,loaded:!1,tool_count:0,tools:[]},l=(i.tools??[]).map(t=>({id:t.runtime_name,title:t.tool_name,subtitle:t.description||e("无描述"),detail:t.display_name,meta:t.runtime_name}));E({open:!0,title:`${t.name||t.note||n} MCP工具`,context_div:(0,_.jsx)(A.O,{title:`${t.name||t.note||n} MCP工具`,subtitle:`${i.transport??"stdio"} | ${i.open?e("是"):e("否")} | ${i.loaded?"loaded":"idle"} | ${i.tool_count} tools`,pages:l,initialPageId:s,onRefresh:async()=>{const e=await fe(n);e&&await we(t,n,s,e)},renderPage:t=>{if(!t)return(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")});const n=i.tools?.find(e=>e.runtime_name===t.id);return n?(0,_.jsxs)("div",{className:"prompt-switch-page__detail",children:[(0,_.jsx)("div",{className:"prompt-switch-page__detail-title",children:n.display_name}),(0,_.jsx)("div",{className:"prompt-switch-page__detail-desc",children:n.description||e("无描述")}),(0,_.jsxs)("div",{className:"prompt-switch-page__detail-row",children:[(0,_.jsx)("strong",{children:"runtime:"})," ",n.runtime_name]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("strong",{children:"schema:"}),(0,_.jsx)("pre",{className:"prompt-switch-page__schema",children:JSON.stringify(n.input_schema??{},null,2)})]})]}):(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")})}}),cancel:()=>E({open:!1})})},ye=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;let t={list:O,docs_update_tag:G.current};null!=e&&(t={param:e}),G.current=!1;(await m.XO.post("ai_docs_setting_save",t)).code===x.m.Success&&(0,j.SK)("保存成功")},Ce=async()=>{for(let e=0;e<oe.length;e++)oe[e].index=e;(await m.XO.post("ai_system_prompts/save",{list:oe})).code===x.m.Success&&(0,j.SK)("保存成功")};return(0,_.jsxs)("div",{children:[(0,_.jsx)(l.A,{children:ae(f.oV.ai_agent_setting)&&(0,_.jsx)(i.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{de(-1)}})}),(0,_.jsx)(c.jW,{isFull:!0,more:!0,children:(0,_.jsx)(c.NN,{children:(0,_.jsxs)(c.xh,{children:[(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:100,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("Model")+" "+e("设置")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 只能使用符合openai风格的ai接口,接口不能只填域名,而是类似 https://ark.cn-beijing.volces.com/api/v3/chat/completions 这样的全路径链接聊天url\n2. 对话的历史越长,消耗的大模型token费用越贵,目前不具备长期记忆简化能力,可以在系统prompt中设置一下让AI回答的简洁一点,节省tokens\n3. model请求参数json编写,里面只能编写json,来用于编写openai风格ai支持的属性,比如 temperature thinking(豆包的深度思考开关)等\n4. 可以在model请求参数中开启 "stream":true 提高响应速度\n5. 深度思考现在会影响输出速度,建议设置`{\n "thinking" : { \n "type":"disabled"\n }\n}`关闭(豆包例子)\n6. 使用AI功能来查询服务器信息,那么AI就需要能够之一些命令,需要先在用户设置中,给用户设置命令权限,建议设置 `*` 允许全部命令,在设置禁止不能执行的危险命令。\n7. 成为tool 后,该模型将会作为一个工具被加载,可以实现不同模型作为不能角色的能力。\n8. model 类型是必须要设置的,因为不同类型的 model 接口格式不同。\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{M([...P,{note:"",open:!1,path:"",dotenv:I.CP,json_params:I.cL}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:async()=>{await je()}})]}),children:(0,_.jsx)(d.X,{headers:n,rows:P.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.url,t.show_options?.options_agent_url_list),options:t.show_options?.options_agent_url_list,handleInputChange:e=>{t.url=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.request_type??"completions",onChange:e=>{t.request_type=e,M([...P])},options:K,no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{((e,t,n)=>{const s=[];for(let e=0;e<P.length;e++)P[e].open=e===n&&t,s.push(P[e]);M(s)})(0,e,n)},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{type:I.Lv.have_label_by_v(t.token,t.show_options?.options_agent_key_list)?null:"password",value:I.Lv.get_label_by_v(t.token,t.show_options?.options_agent_key_list),options:t.show_options?.options_agent_key_list,handleInputChange:e=>{t.token=e},no_border:!0}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.model,t.show_options?.options_agent_model_list),options:t.show_options?.options_agent_model_list,handleInputChange:e=>{t.model=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.tool_mode,onChange:n=>{t.open&&!0===n?(0,j.zN)(e("开启状态不能成为tool")):(t.tool_mode=n,M([...P]))},options:ue,no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"short_text",title:"prompt",onClick:()=>{g.xK.set_value_temp(P[n].sys_prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{P[n].sys_prompt=e,M(P),g.xK.set_value_temp(""),je(P)}})}}),(0,_.jsx)(i.rA,{icon:"edit_attributes",title:"model请求参数json编写",onClick:()=>{g.xK.set_value_temp(P[n].json_params),ce({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{P[n].json_params=e,M(P),g.xK.set_value_temp(""),je(P)},can_format:!0})}}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(P[n].dotenv),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{P[n].dotenv=e,M(P),g.xK.set_value_temp(""),je(P)}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{P.splice(e,1),M([...P])})(n)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>(e=>{M([...P,{...P[e],open:!1}])})(n)})]})];return s}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:70,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - stdio"]})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 这里配置的是 MCP Client 启动参数,当前实现的是 stdio 模式,也就是通过 command + args 启动本地 MCP Server\n2. 例如可以填 npx / uvx / python 等命令,再配合对应的 MCP server 包参数\n3. 保存后会自动重新加载 MCP 工具,agent 聊天时会把这些工具一起带给模型\n4. 建议把 cwd 配到具体项目目录,避免 server 在错误目录里运行\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("stdio")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:te,rows:Q.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.command,handleInputChange:e=>{t.command=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.args,handleInputChange:e=>{t.args=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.cwd,handleInputChange:e=>{t.cwd=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"env",onClick:()=>{g.xK.set_value_temp(t.env??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.env=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsxs)(c.VP,{widthPer:70,children:[(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - HTTP"]})," "]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("http")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:ne,rows:ee.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.endpoint,handleInputChange:e=>{t.endpoint=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"headers",onClick:()=>{g.xK.set_value_temp(t.headers??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.headers=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})}),(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("系统会话提示词")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 系统会话提示词,在 AI 聊天页创建会话时可以选择,选中的提示词会自动填入聊天框作为第一条系统消息\n2. 适用于预先设定常用的会话场景模板,如"代码审查"、"翻译助手"、"运维诊断"等\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{ie([...oe,{prompt:"",note:""}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{Ce()}})]}),children:(0,_.jsx)(d.X,{headers:se,rows:oe.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"short_text",title:e("提示词"),onClick:()=>{g.xK.set_value_temp(t.prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.prompt=e,ie([...oe]),g.xK.set_value_temp(""),Ce()}})}})}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{oe.splice(e,1),ie([...oe])})(n)})})];return s}),width:"10rem"})})]})}),(0,_.jsxs)(c.fI,{children:[(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("本地知识库")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 本地知识库用于为AI增强理解能力,或者分析本地文件,原理读取本地的文件,对文件在内存中建立全文索引,为AI提供额外数据(需要有模型开启才能使用)\n2. 该功能只能用于小型知识库,作为本地小型或者公司内部资料使用还是没有问题的\n3. 每次保存都会重新加载知识库中的文件,不会全部重新加载,而是检测哪些文件有变更\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.Ay,{checked:U,onChange:async e=>{await m.jV.post("docs_on_set",{status:e}),he(),t()},title:e("知识库开关")}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(Y.current),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{Y.current=e,g.xK.set_value_temp(""),ye(Y.current)}})}}),(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...O,{note:"",auto_load:!1,dir:""}]),G.current=!0}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ye()}})]}),children:(0,_.jsx)(d.X,{headers:N,rows:O.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.dir,handleInputChange:e=>{t.dir=e,G.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.auto_load,onChange:e=>{t.auto_load=e,X([...O]),G.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除记录"),onClick:()=>(e=>{O.splice(e,1),X([...O]),G.current=!0})(n)}),(0,_.jsx)(i.rA,{icon:"restore",title:e("手动加载"),onClick:()=>{pe({sub_title:"手动加载",confirm_fun:()=>{m.jV.post("ai_load_one_file",{param_path:t.dir}),(0,j.SK)("ok")}})}}),(0,_.jsx)(i.rA,{icon:"delete_forever",title:e("从索引删除"),onClick:()=>{pe({sub_title:"从索引删除",confirm_fun:()=>{m.jV.post("ai_del",{param_path:t.dir}),(0,j.SK)("ok")}})}})]})];return s}),width:"10rem"})})}),H&&(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsxs)(u.Zp,{title:e("知识库加载信息"),children:[(0,_.jsx)(c.Yh,{left:e("最近一次加载")+","+e("加载进度"),right:H?.progress}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件数量")}`,right:H?.num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件字符数量")}`,right:H?.char_num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件大小")}`,right:(0,k.v7)(H?.size)}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总耗时")}`,right:(0,k.a3)(H?.consume_time_ms_len)}),(0,_.jsx)(c.Yh,{left:`${e("总文件数量")}`,right:H?.total_num})]})})]})]})})})]})}},96494(e,t,n){n.d(t,{r:()=>o});var s=n(22022);function o(){const{t:e}=(0,s.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},34299(e,t,n){n.r(t),n.d(t,{default:()=>m});n(96540);var s=n(73557),o=n(53995),i=n(18569),l=n(77979),a=n(8263),r=n(69428),c=n.n(r),d=(n(3775),n(21499)),p=n(99214),u=n(19878),h=(n(72411),n(74848));const _=new s.A({html:!0,highlight:function(e,t){if(t&&u.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${u.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${u.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${_.utils.escapeHtml(e)}</code></pre>`}});function m(e){return(0,p.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:_.render(e.context)}})}_.use(o.A).use(i.A).use(l.A).use(a.A).use(c()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,n,s,o,i)=>{const l=t[n],a=l.content.trim(),r=l.info.trim();let c="";if(r&&u.A.getLanguage(r))try{c=u.A.highlight(a,{language:r}).value}catch(t){c=e.utils.escapeHtml(a)}else try{c=u.A.highlightAuto(a).value}catch(t){c=e.utils.escapeHtml(a)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(a)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${c}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,n,s,o){return o.renderToken(e,t,n)};e.renderer.rules.link_open=(e,n,s,o,i)=>{const l=e[n],a=l.attrIndex("href");if(a>=0){const e=l.attrs[a][1];l.attrs[a][1]=(0,d.bi)(window.location.href,e)}return t(e,n,s,o,i)}})},45907(e,t,n){n.d(t,{y:()=>i});var s=n(34843),o=n(82893);function i(){const[e,t]=(0,s.fp)(o.AG.confirm);return({sub_title:e,confirm_fun:n,title:s,context_div:o})=>{t({open:!0,sub_title:e,handle:()=>{n(),t({open:!1,handle:null})},title:s,context_div:o})}}},24659(e,t,n){var s=n(22022);n.d(t,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,9782],{83277(e,t,s){s.d(t,{$j:()=>c,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list}class a{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const s of t)if(s.value===e)return s.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const s of t)if(s.value===e)return!0;return!1}}class i extends n{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url}const l=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function c(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}s.d(t,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n',"cL",0,l])},86271(e,t,s){s.r(t),s.d(t,{default:()=>M});var n=s(96540),a=s(14284),i=s(7463),l=s(57952),c=s(85997),r=s(78247),o=s(23430),d=s(40505),u=s(62042),m=s(22022),h=s(45907),p=s(53459),g=s(87361),x=s(61973),_=s(34843),j=s(82893),f=s(27690),v=s(61443),y=s(72693),b=s(83277),S=s(74848);function w({sessions:e,activeSessionId:t,onSelectSession:s,onRenameSession:a,onDeleteSession:i,onShowUsageStats:l,batchMode:r,selectedSessionIds:o,onToggleSessionSelect:d}){const{t:u}=(0,m.Bd)(),[h,p]=(0,_.fp)(j.AG.ai_session_collapsed),[g,x]=(0,n.useState)(""),v=g.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(g.toLowerCase())||(e.summary||"").toLowerCase().includes(g.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(g.toLowerCase())):e;return(0,S.jsxs)("aside",{className:`chat-session-list ${h?"active":""} ${h?"collapsed":""}`,children:[!h&&(0,S.jsx)("div",{className:"chat-session-search",children:(0,S.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:u("搜索会话"),value:g,onChange:e=>x(e.target.value)})}),v.map(e=>{return(0,S.jsx)("div",{children:(0,S.jsxs)("button",{className:`chat-session-item ${t===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&d?d(e.id):s(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,S.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:o?.has(e.id)??!1,onChange:()=>d?.(e.id),onClick:e=>e.stopPropagation()}),(0,S.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,S.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,S.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,S.jsx)(f.MenuSelect,{list:[{name:u("重命名"),click:()=>a(e.id,e.title)},{name:u("字符消耗统计"),click:()=>l(e.id)},{name:u("删除"),click:()=>i(e.id)}],children:(0,S.jsx)(c.In,{icon:"more_horiz"})})]})},e.id);var n})]})}function N({pendingAttachments:e,onRemove:t}){return 0===e.length?null:(0,S.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,s)=>(0,S.jsxs)("div",{className:"chat-attachment-chip",children:[(0,S.jsx)(c.In,{icon:"attach_file"}),(0,S.jsx)("span",{title:e.name,children:e.name}),(0,S.jsx)("button",{type:"button",onClick:()=>t(s),children:(0,S.jsx)(c.In,{icon:"close"})})]},`${e.name}_${s}`))})}function k({inputValue:e,onInputChange:t,onKeyDown:s,onPaste:n,onSend:a,sending:i,pendingAttachments:l,onRemoveAttachment:r,onOpenFilePicker:o,onAddFiles:d,onDrop:u,onDragOver:h,fileInputRef:p}){const{t:g}=(0,m.Bd)();return(0,S.jsxs)("div",{className:"chat-input-area",onDrop:u,onDragOver:h,children:[(0,S.jsx)("input",{ref:p,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(d(e.target.files),e.currentTarget.value="")}}),(0,S.jsxs)("div",{className:"chat-input-shell",children:[(0,S.jsx)(N,{pendingAttachments:l,onRemove:r}),(0,S.jsx)("textarea",{value:e,onChange:t,onPaste:n,onKeyDown:s,placeholder:g("输入消息"),className:"chat-input"})]}),(0,S.jsx)(c.rA,{title:g("添加文件"),icon:"attach_file",onClick:o}),!1===i?(0,S.jsx)(c.Vi,{text:g("发送"),clickFun:a}):(0,S.jsx)("div",{className:"ai-thinking-indicator",children:(0,S.jsxs)("div",{className:"ai-thinking-dots",children:[(0,S.jsx)("div",{className:"ai-thinking-dot"}),(0,S.jsx)("div",{className:"ai-thinking-dot"}),(0,S.jsx)("div",{className:"ai-thinking-dot"})]})})]})}var A=s(96494);function C(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}catch{}return{size:"1024x1024",n:1}}function I({onClose:e}){const{t}=(0,m.Bd)(),[s,a]=(0,n.useState)(C),[i,l]=(0,n.useState)(s.size||"1024x1024"),[r,o]=(0,n.useState)(String(s.n??1)),[d,u]=(0,n.useState)(s.quality||""),[h,p]=(0,n.useState)(s.style||""),[g,x]=(0,n.useState)(s.extra_json||"");return(0,S.jsxs)("div",{className:"card images-params-card",children:[(0,S.jsx)("h3",{children:t("图片生成参数设置")}),(0,S.jsx)("p",{className:"images-params-hint",children:"不同模型支持的参数不同,请参考模型文档。常见 size 值: 1024x1024, 1792x1024, 1024x1792 (DALL-E 3)"}),(0,S.jsxs)("div",{className:"images-params-fields",children:[(0,S.jsxs)("div",{children:[(0,S.jsx)("label",{children:"size (图片尺寸)"}),(0,S.jsx)(v.Sm,{value:i,handleInputChange:l,no_border:!1})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)("label",{children:"n (生成数量)"}),(0,S.jsx)(v.Sm,{value:r,handleInputChange:o,no_border:!1})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)("label",{children:'quality (画质, 如 "standard" / "hd")'}),(0,S.jsx)(v.Sm,{value:d,handleInputChange:u,no_border:!1})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)("label",{children:'style (风格, 如 "vivid" / "natural")'}),(0,S.jsx)(v.Sm,{value:h,handleInputChange:p,no_border:!1})]}),(0,S.jsxs)("div",{children:[(0,S.jsx)("label",{children:"额外参数 (JSON,会合并到请求体中)"}),(0,S.jsx)(v.Sm,{value:g,handleInputChange:x,no_border:!1})]})]}),(0,S.jsxs)("div",{className:"images-params-actions",children:[(0,S.jsx)(c.rA,{icon:"close",title:t("取消"),onClick:e}),(0,S.jsx)(c.rA,{icon:"save",title:t("保存"),onClick:()=>{const t={size:i,n:parseInt(r)||1};d&&(t.quality=d),h&&(t.style=h),g&&(t.extra_json=g),function(e){localStorage.setItem("ai_images_extra_params",JSON.stringify(e))}(t),e()}})]})]})}function $(){const{t:e}=(0,m.Bd)(),[t,s]=(0,_.fp)(j.AG.ai_request_type),[a,i]=(0,n.useState)(!1),l=(0,A.r)(),c=l.find(e=>e.value===t)??l[0];return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(f.MenuSelect,{list:[...l.map(e=>({name:e.label,click:()=>s(e.value)})),..."images"===t?[{name:e("图片参数设置"),click:()=>i(!0)}]:[],..."audio_speech"===t?[{name:e("语音参数设置"),click:()=>{const t=localStorage.getItem("ai_audio_extra_params"),s=t?JSON.parse(t):{},n=s.voice||"alloy",a=s.speed||"1.0",i=prompt(e("输入 voice (如 alloy, echo, fable, onyx, nova, shimmer)"),n);if(null!==i){const t=prompt(e("输入 speed (0.25 ~ 4.0)"),a);null!==t&&localStorage.setItem("ai_audio_extra_params",JSON.stringify({voice:i,speed:parseFloat(t)||1}))}}}]:[]],children:(0,S.jsxs)("div",{className:"menu-select-trigger",children:[(0,S.jsx)("span",{children:c.label}),(0,S.jsx)("span",{className:"menu-select-arrow",children:"▾"})]})}),a&&(0,S.jsx)("div",{className:"modal-overlay",onClick:()=>i(!1),children:(0,S.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,S.jsx)(I,{onClose:()=>i(!1)})})})]})}var O=s(34299);function D(e){const t=e.attachments&&e.attachments.length>0?(0,S.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,t)=>(0,S.jsxs)("div",{className:"chat-message-attachment",children:[(0,S.jsx)(c.In,{icon:"attach_file"}),(0,S.jsx)("span",{children:e.name}),(0,S.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${t}`))}):null,s=[];e.images&&"bot"===e.sender&&s.push((0,S.jsx)(n.Fragment,{children:(0,S.jsx)(V,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&s.push((0,S.jsx)(n.Fragment,{children:(0,S.jsx)(J,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&s.push((0,S.jsx)(n.Fragment,{children:(0,S.jsx)(L,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=e.call_list&&e.call_list.length>0&&"bot"===e.sender?(0,S.jsx)(n.Fragment,{children:(0,S.jsx)(F,{callList:e.call_list})},"call_list"):null;return 0===s.length?(0,S.jsxs)(S.Fragment,{children:[a,t,(0,S.jsx)(O.default,{context:e.text})]}):(0,S.jsxs)(S.Fragment,{children:[s,a,t,e.text&&(0,S.jsx)(O.default,{context:e.text})]})}function F({callList:e}){const[t,s]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,S.jsxs)("div",{className:"chat-message-call-list",children:[(0,S.jsxs)("div",{className:"call-list-header",onClick:()=>s(!t),children:[(0,S.jsx)(c.In,{icon:t?"expand_less":"expand_more"}),(0,S.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,S.jsxs)("span",{className:"call-list-fail",children:[" 失败: ",a]})]})]}),t&&(0,S.jsx)("div",{className:"call-list-body",children:e.map((e,t)=>(0,S.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,S.jsxs)("div",{className:"call-list-item-header",children:[(0,S.jsx)(c.In,{icon:e.success?"check_circle":"error"}),(0,S.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,S.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,S.jsxs)("details",{className:"call-list-details",children:[(0,S.jsx)("summary",{children:"参数"}),(0,S.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,S.jsxs)("details",{className:"call-list-details",children:[(0,S.jsx)("summary",{children:"错误"}),(0,S.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,S.jsxs)("details",{className:"call-list-details",children:[(0,S.jsx)("summary",{children:"结果"}),(0,S.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},t))})]})}function V({images:e,text:t}){let s=e||[];if(!s.length&&t)try{s=JSON.parse(t).data||[]}catch{}return s.length?(0,S.jsxs)("div",{className:"image-generation-result",children:[s.map((e,t)=>(0,S.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,S.jsx)("div",{className:"image-generation-image-wrapper",children:(0,S.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${t+1}`,loading:"lazy"})}),e.b64_json&&(0,S.jsx)("div",{className:"image-generation-image-wrapper",children:(0,S.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${t+1}`})}),e.revised_prompt&&(0,S.jsx)("p",{className:"image-generation-prompt",children:(0,S.jsx)("small",{children:e.revised_prompt})})]},t)),t&&!e&&(0,S.jsx)(O.default,{context:t})]}):(0,S.jsx)(O.default,{context:t||""})}function J({audio:e,text:t}){if(e){if(e.url)return(0,S.jsx)("div",{className:"audio-result",children:(0,S.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const t=e.mime_type||"audio/mpeg";return(0,S.jsx)("div",{className:"audio-result",children:(0,S.jsx)("audio",{controls:!0,src:`data:${t};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const s=t||"";if(s.startsWith("http://")||s.startsWith("https://"))return(0,S.jsx)("div",{className:"audio-result",children:(0,S.jsx)("audio",{controls:!0,src:s,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(s);if(e?.data||e?.audio_data){const t=e.data||e.audio_data;return(0,S.jsx)("div",{className:"audio-result",children:(0,S.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${t}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,S.jsx)(O.default,{context:s})}function z({content:e,label:t}){const[s,a]=n.useState(!1);return(0,S.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,d.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,S.jsx)(c.In,{icon:s?"check":"content_copy"}),s?"已复制":t||"复制"]})}function L({embeddings:e,text:t}){let s=e||null;if(!s&&t)try{s=JSON.parse(t)}catch{return(0,S.jsx)(O.default,{context:t})}if(!s)return(0,S.jsx)(O.default,{context:t||""});const n=s?.data||[],a=s?.usage,i=JSON.stringify(s,null,2);return(0,S.jsxs)("div",{className:"embeddings-result",children:[(0,S.jsxs)("div",{className:"embeddings-summary",children:[(0,S.jsx)("strong",{children:"向量嵌入结果"}),(0,S.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,S.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,S.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,S.jsxs)("div",{className:"embeddings-toolbar",children:[(0,S.jsx)(z,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,S.jsx)(z,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,S.jsx)(z,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,S.jsx)("div",{className:"embeddings-preview",children:(0,S.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,S.jsxs)("details",{children:[(0,S.jsx)("summary",{children:"查看详细数据"}),(0,S.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function R(e,t){const s=function(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}catch{}return{}}(),n={prompt:e,n:s.n??1,size:s.size??"1024x1024",session_id:t};if(s.quality&&(n.quality=s.quality),s.style&&(n.style=s.style),s.extra_json)try{const e=JSON.parse(s.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const i=await a.jV.post("images/generations",n);if(0!==i.code)throw new Error(i.message||"图片生成失败");const l=i.data||{},c=(l.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),r=c.map((e,t)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:l.session_id||t,images:c,text:r||`生成了 ${c.length} 张图片`}}async function q(e,t,s,n){try{switch(e){case"images":{const e=await R(t,s);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,t){const s={input:e,session_id:t};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const t=JSON.parse(e);t.voice&&(s.voice=t.voice),t.speed&&(s.speed=parseFloat(t.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(s)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||t,l=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(l)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(t,s);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,t){const s=await a.jV.post("embeddings",{input:e,session_id:t});if(0!==s.code)throw new Error(s.message||"Embeddings 请求失败");const n=s.data||{},i=n?.data??[],l=`向量维度: ${i[0]?.embedding?.length??0}, 数量: ${i.length}`;return{session_id:n.session_id||t,embeddings:n,text:`✅ Embeddings 结果 - ${l}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(t,s);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}function H(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i.test(e.name)?"text":"binary"}function E(e){return e.text()}function B(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=s,n.readAsDataURL(e)})}function M(){const[e,t]=(0,n.useState)([]),[s,N]=(0,n.useState)([]),[C,I]=(0,n.useState)(""),[O,F]=(0,_.fp)(j.AG.ai_session_collapsed),[V,J]=(0,n.useState)([]),[z,L]=(0,_.fp)(j.AG.ai_request_type);(0,y.w)();const R=(0,A.r)(),{t:M}=(0,m.Bd)(),T=(0,n.useRef)(null),[K,P]=(0,_.fp)(j.AG.prompt_card),[G,W]=(0,n.useState)(!1),[U,X]=(0,n.useState)(new Set),[Z,Q]=(0,n.useState)(new Set),Y=(0,n.useRef)((0,i.sg)(e=>{t(e),oe.current&&ge(!1)},50)).current,[ee,te]=(0,n.useState)(!1),{check_user_auth:se}=(0,r.MH)(),[ne,ae]=(0,n.useState)(""),ie=(0,n.useRef)(null),le=(0,n.useRef)(null),ce=(0,h.y)(),re=(0,x.Zp)(),oe=(0,n.useRef)(!0),de=(0,n.useRef)(new b.qq),[ue,me]=(0,n.useState)([]),[he,pe]=(0,n.useState)(""),ge=(e=!1)=>{const t=le.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},xe=e=>{const t=Array.from(e??[]).filter(Boolean);t.length&&J(e=>[...e,...t])},_e=async e=>{const s=await a.jV.get("sessions");if(s.code!==p.m.Success)return;const n=s.data??[];N(n);const i=null===e?n[0]?.id??"":e||C||n[0]?.id||"";i?await fe(i):(t([]),I(""))},je=async()=>{const e=await a.jV.get("sessions");e.code===p.m.Success&&N(e.data??[])},fe=async(e,s=!1)=>{const n=await a.jV.post("session/get",{session_id:e});if(n.code!==p.m.Success||!n.data)return;const i=n.data;I(i.id),t(function(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,t)=>({id:Date.now()+t,sender:"assistant"===e.role?"bot":"user",text:(0,b.$j)(e.content),attachments:e.attachments??[],images:e.images,audio:e.audio,embeddings:e.embeddings,call_list:e.call_list}))}(i.messages)),s&&F(!1),requestAnimationFrame(()=>ge(!1))},ve=async e=>{const s=await a.jV.post("session",{title:"新会话"});if(s.code!==p.m.Success)return;const n=s.data;I(n.id),e?(ae(e),t([])):t([]),F(!1),await _e(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})};(0,n.useEffect)(()=>{(async()=>{const e=await a.XO.get("ai_agent_setting/env");if(e.code===p.m.Success){de.current=e.data;const t=e.data.current_model_note||"",s=(e.data.options_agent_model_list??[]).find(e=>e.label===t);pe(s?s.value:t)}await _e();const t=await a.jV.get("system_prompts");t.code===p.m.Success&&me(t.data??[])})(),requestAnimationFrame(()=>{ge(!1)})},[]),(0,n.useEffect)(()=>{const e=le.current;if(!e)return;const t=()=>{oe.current=((e,t=120)=>{const{scrollTop:s,scrollHeight:n,clientHeight:a}=e;return n-(s+a)<t})(e)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]),(0,n.useLayoutEffect)(()=>{oe.current&&ge(!1)},[e]);const ye=e=>{const t=(e.attachments??[]).filter(e=>"image"===e.kind);if(t.length>0){const s=[];e.text&&s.push({type:"text",text:e.text});for(const e of t)s.push({type:"image_url",image_url:{url:e.content}});return[{content:s,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},be=async()=>{const s=ne.trim();if(ee||!s&&0===V.length)return;let n=C;if(!n){const e=await a.jV.post("session",{title:(s||V[0]?.name||"新会话").slice(0,28)});if(e.code!==p.m.Success)return;n=e.data.id,I(n),await _e(n)}const i=await(async e=>{const t=[];for(const s of e){const e=H(s);let n="";if("text"===e)try{const e=await E(s),t=12e4;n=e.length>t?`${e.slice(0,t)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await B(s)}catch{n=`[图片文件: ${s.name}]`}else n=`[二进制文件: ${s.name}]`;t.push({name:s.name,mime_type:s.type,size:s.size,kind:e,content:n})}return t})(V),l={id:Date.now(),sender:"user",text:s,attachments:i},c=[...e,l];if(t(c),ae(""),J([]),te(!0),"completions"!==z){const e={id:l.id+1,sender:"bot",text:"处理中..."};c.push(e),t([...c]);return void(await q(z,s,n,async(s,n)=>{e.text=s,n?.images&&(e.images=n.images),n?.audio&&(e.audio=n.audio),n?.embeddings&&(e.embeddings=n.embeddings),t([...c]),te(!1),je(),ge(!0)})||(e.text=`请求类型 "${z}" 的专用处理器尚未实现,请使用 completions 类型。`,t([...c]),te(!1)))}const r={id:l.id+1,sender:"bot",text:"AI思考中..."};c.push(r),t([...c]);let o=!0;a.jV.sse_post("chat",{messages:ye(l),session_id:n},{onMessage:e=>{o&&(r.text="",o=!1);try{const t=JSON.parse(e),s="string"==typeof t?t:t?.choices?.[0]?.delta?.content??t?.choices?.[0]?.message?.content;s&&(r.text+=s)}catch(t){try{r.text+=JSON.parse(e)}catch(t){r.text+=e}}Y([...c])},onDone:async e=>{te(!1),e?.call_list?.length&&(r.call_list=e.call_list,t([...c])),await je(),ge(!0)}})},Se=e=>null==e||e<0?"0":e.toLocaleString();return(0,S.jsxs)(n.Fragment,{children:[(0,S.jsxs)(l.A,{children:[(0,S.jsx)(c.rA,{icon:"menu",title:M("会话"),onClick:()=>{window.innerWidth<=736?F(!0):F(e=>!e)}}),(0,S.jsx)(c.rA,{icon:"add",title:M("新会话"),onClick:()=>ve()}),ue.length>0&&(0,S.jsx)(f.MenuSelect,{list:ue.map((e,t)=>({name:e.note||`${M("提示词")} ${t+1}`,click:()=>{e.prompt&&ve(e.prompt)}})),children:(0,S.jsx)(c.rA,{icon:"add_comment",title:M("提示词模板创建会话")})}),(0,S.jsx)($,{}),(de.current?.options_agent_model_list?.length??0)>0&&(0,S.jsx)(v.l6,{value:he,options:de.current.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{pe(e),a.jV.post("set_active_model",{model_name:e}).then(()=>{(0,u.SK)("success"),a.XO.get("ai_agent_setting/env").then(e=>{e.code===p.m.Success&&(de.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),(0,S.jsx)(c.rA,{icon:G?"check_circle":"checklist",title:M(G?"取消批量选择":"批量选择"),onClick:()=>{G&&(X(new Set),Q(new Set)),W(e=>!e)}}),G&&U.size>0&&(0,S.jsx)(c.rA,{icon:"delete",title:M("删除选中消息"),onClick:()=>{0!==U.size&&ce({sub_title:M("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const s=[];e.forEach((e,t)=>{U.has(e.id)&&s.push(t)});const n=e.filter(e=>!U.has(e.id));t(n),X(new Set),W(!1),C&&s.length>0&&a.jV.post("session/message/delete",{session_id:C,indices:s}).catch(console.error)}})}}),G&&Z.size>0&&(0,S.jsx)(c.rA,{icon:"delete",title:M("删除选中会话"),onClick:()=>{0!==Z.size&&ce({sub_title:M("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Z)await a.jV.post("session/delete",{session_id:e});Q(new Set),W(!1),Z.has(C)?(I(""),await _e(null)):await _e(C)}})}}),(0,S.jsx)(c.rA,{icon:"delete_sweep",title:M("清空全部会话"),onClick:()=>{ce({sub_title:M("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await a.jV.post("sessions/clear",{}),I(""),t([]),await _e(null)}})}}),se(o.oV.ai_agent_setting)&&(0,S.jsx)(c.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{re(`/${g.o.ai_rebot_setting_page}`)}}),se(o.oV.ai_agent_setting)&&(0,S.jsx)(c.rA,{icon:"settings",title:"ai setting",onClick:()=>{re(`/${g.o.ai_agent_setting_page}`)}})]}),(0,S.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[O&&(0,S.jsx)("div",{className:"chat-session-overlay",onClick:()=>F(!1)}),(0,S.jsx)(w,{sessions:s,activeSessionId:C,onSelectSession:e=>fe(e,!1),onRenameSession:(e,t)=>{let s=t;ce({confirm_fun:async()=>{await a.jV.post("sessions/update/meta",{id:e,title:s}),await _e(C)},context_div:(0,S.jsx)("div",{className:"card-content",children:(0,S.jsx)(v.Sm,{value:s,handleInputChange:e=>s=e})})})},onDeleteSession:e=>{ce({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await a.jV.post("session/delete",{session_id:e}),C===e?(I(""),await _e(null)):await _e(C)}})},onShowUsageStats:async e=>{P({open:!0,title:M("字符消耗统计"),context_div:(0,S.jsx)("div",{className:"usage-stats-loading",children:M("加载中...")}),cancel:()=>P({open:!1})});try{const t=await a.jV.post("session/usage_stats",{session_id:e});if(t.code===p.m.Success&&t.data){const e=t.data;P({open:!0,title:M("字符消耗统计"),context_div:(0,S.jsxs)("div",{className:"usage-stats-panel",children:[[{l:M("对话轮次"),v:(e.turns??0).toString()},{l:M("AI输入字符"),v:Se(e.input_chars)},{l:M("AI输出字符"),v:Se(e.output_chars)},{l:M("AI输入字符(最近一轮)"),v:Se(e.recent_input_chars)},{l:M("AI输出字符(最近一轮)"),v:Se(e.recent_output_chars)}].map((e,t)=>(0,S.jsxs)("div",{className:"usage-stats-row",children:[(0,S.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,S.jsx)("span",{className:"usage-stats-value",children:e.v})]},t)),(0,S.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,S.jsx)("span",{className:"usage-stats-label",children:M("AI字符总计消耗")}),(0,S.jsx)("span",{className:"usage-stats-value",children:Se((e.input_chars||0)+(e.output_chars||0))})]})]}),cancel:()=>P({open:!1})})}else P({open:!0,title:M("字符消耗统计"),context_div:(0,S.jsx)("div",{className:"usage-stats-empty",children:M("暂无统计数据")}),cancel:()=>P({open:!1})})}catch{P({open:!0,title:M("字符消耗统计"),context_div:(0,S.jsx)("div",{className:"usage-stats-empty",children:M("暂无统计数据")}),cancel:()=>P({open:!1})})}},batchMode:G,selectedSessionIds:Z,onToggleSessionSelect:e=>{Q(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}),(0,S.jsxs)("section",{className:"chat-main",children:[0===e?.length&&(0,S.jsx)("div",{className:"chat-header",children:(0,S.jsx)("div",{children:"completions"===z?M("询问服务器的一切"):R.find(e=>e.value===z)?.label??z})}),(0,S.jsxs)("div",{className:"chat-messages",ref:le,children:[e.map(s=>(0,S.jsxs)("div",{className:`chat-message ${s.sender} ${G?"batch-mode":""}`,children:[G&&(0,S.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:U.has(s.id),onChange:()=>{return e=s.id,void X(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s});var e}}),D(s),!G&&(0,S.jsxs)("div",{className:"message-actions",children:[(0,S.jsx)("button",{onClick:()=>{return n=s.id,void ce({sub_title:M("确认删除这条消息吗?"),confirm_fun:async()=>{const s=e.findIndex(e=>e.id===n);if(s<0)return;const i=e.filter(e=>e.id!==n);t(i),C&&a.jV.post("session/message/delete",{session_id:C,indices:[s]}).catch(console.error)}});var n},children:M("删除")}),(0,S.jsx)("button",{onClick:()=>(async e=>{(0,d.lW)(e),(0,u.SK)("复制成功")})(s.text),children:M("复制")})]})]},s.id)),(0,S.jsx)("div",{ref:ie})]}),(0,S.jsx)(k,{inputValue:ne,onInputChange:e=>{const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,200)+"px",ae(t.value)},onKeyDown:e=>{"Process"===e.key||e.nativeEvent.isComposing||e.shiftKey||e.ctrlKey||"Enter"===e.key&&(e.preventDefault(),be())},onPaste:e=>{const t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),xe(t))},onSend:be,sending:ee,pendingAttachments:V,onRemoveAttachment:e=>{J(t=>t.filter((t,s)=>s!==e))},onOpenFilePicker:()=>{T.current?.click()},onAddFiles:xe,onDrop:e=>{const t=e.dataTransfer?.files;t&&t.length>0&&(e.preventDefault(),xe(t))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:T})]})]})]})}},96494(e,t,s){s.d(t,{r:()=>a});var n=s(22022);function a(){const{t:e}=(0,n.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},72693(e,t,s){s.d(t,{w:()=>u});var n=s(96540),a=s(22022),i=s(14944),l=s(92275),c=s(34843),r=s(82893),o=s(85997),d=s(74848);function u(){const[e,t]=(0,c.fp)(r.AG.prompt_card),{t:s}=(0,a.Bd)(),u=(0,n.useRef)([]),m=(0,n.useRef)(!1),h=(0,n.useCallback)(()=>{if(m.current)return;if(0===u.current.length)return m.current=!1,void t({open:!1});m.current=!0;const e=u.current.shift();e?t({open:!0,title:s("命令确认"),cancel:()=>{i.ws.sendData(l.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()},context_div:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),(0,d.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,d.jsx)(o.$n,{text:s("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(l.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()}}),(0,d.jsx)(o.$n,{text:s("允许"),clickFun:()=>{i.ws.sendData(l.HK.ai_confirm_cmd,{askId:e.askId,approved:!0}),t({open:!1}),m.current=!1,h()}})]})]})}):m.current=!1},[s]),p=(0,n.useCallback)(e=>{u.current.push(e),h()},[h]);(0,n.useEffect)(()=>(i.ws.addMsg(l.HK.ai_confirm_cmd,e=>{const s=e.context||{};if(s.dismiss&&s.askId)return u.current=u.current.filter(e=>e.askId!==s.askId),void(m.current&&(m.current=!1,t({open:!1}),h()));s.askId&&s.cmd&&p({askId:s.askId,cmd:s.cmd})}),()=>{i.ws.removeMsg(l.HK.ai_confirm_cmd)}),[p]),(0,n.useEffect)(()=>()=>{u.current=[],m.current=!1},[])}},34299(e,t,s){s.r(t),s.d(t,{default:()=>g});s(96540);var n=s(73557),a=s(53995),i=s(18569),l=s(77979),c=s(8263),r=s(69428),o=s.n(r),d=(s(3775),s(21499)),u=s(99214),m=s(19878),h=(s(72411),s(74848));const p=new n.A({html:!0,highlight:function(e,t){if(t&&m.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${m.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${p.utils.escapeHtml(e)}</code></pre>`}});function g(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:p.render(e.context)}})}p.use(a.A).use(i.A).use(l.A).use(c.A).use(o()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,s,n,a,i)=>{const l=t[s],c=l.content.trim(),r=l.info.trim();let o="";if(r&&m.A.getLanguage(r))try{o=m.A.highlight(c,{language:r}).value}catch(t){o=e.utils.escapeHtml(c)}else try{o=m.A.highlightAuto(c).value}catch(t){o=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${o}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,s,n,a){return a.renderToken(e,t,s)};e.renderer.rules.link_open=(e,s,n,a,i)=>{const l=e[s],c=l.attrIndex("href");if(c>=0){const e=l.attrs[c][1];l.attrs[c][1]=(0,d.bi)(window.location.href,e)}return t(e,s,n,a,i)}})},45907(e,t,s){s.d(t,{y:()=>i});var n=s(34843),a=s(82893);function i(){const[e,t]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:s,title:n,context_div:a})=>{t({open:!0,sub_title:e,handle:()=>{s(),t({open:!1,handle:null})},title:n,context_div:a})}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|
|
File without changes
|