@nocobase/plugin-ai 2.1.0-alpha.33 → 2.1.0-alpha.34
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/dist/client/119.c6bf8c6433167d81.js +10 -0
- package/dist/client/228.b4b709f93b86b6b9.js +10 -0
- package/dist/client/{486.afbed6b132b3c0dd.js → 486.dcac8f3fcec19c33.js} +1 -1
- package/dist/client/597.b0d64948d74cf6cb.js +10 -0
- package/dist/client/646.5860101cb28c8272.js +10 -0
- package/dist/client/711.92cd94681fde7e05.js +10 -0
- package/dist/client/768.5177bff46ae71a5b.js +10 -0
- package/dist/client/792.abb57765453bcbcc.js +10 -0
- package/dist/client/820.f72ef2462b61d812.js +10 -0
- package/dist/client/927.ac9ee9a8c1cb4f1d.js +10 -0
- package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +1 -15
- package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +1 -21
- package/dist/client/ai-employees/chatbox/hooks/useChat.d.ts +125 -0
- package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +1 -1
- package/dist/client/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +13 -1
- package/dist/client/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +8 -8
- package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
- package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +77 -50
- package/dist/client/ai-employees/chatbox/stores/chat-tool-call.d.ts +24 -16
- package/dist/client/ai-employees/types.d.ts +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +4 -4
- package/dist/externalVersion.js +16 -15
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-conversations.d.ts +3 -1
- package/dist/server/ai-employees/ai-conversations.js +40 -3
- package/dist/server/ai-employees/ai-employee.d.ts +16 -14
- package/dist/server/ai-employees/ai-employee.js +65 -43
- package/dist/server/ai-employees/middleware/conversation.js +11 -9
- package/dist/server/collections/ai-conversations.js +6 -0
- package/dist/server/manager/llm-stream-manager.d.ts +37 -0
- package/dist/server/manager/llm-stream-manager.js +142 -0
- package/dist/server/plugin.d.ts +2 -0
- package/dist/server/plugin.js +3 -0
- package/dist/server/resource/aiConversations.d.ts +8 -0
- package/dist/server/resource/aiConversations.js +129 -2
- package/package.json +2 -2
- package/dist/client/119.78774f3ad953af49.js +0 -10
- package/dist/client/228.a3df2921c8beb766.js +0 -10
- package/dist/client/597.aa363881a325b5c0.js +0 -10
- package/dist/client/646.217a40387efbd163.js +0 -10
- package/dist/client/711.266b8f1c520d467a.js +0 -10
- package/dist/client/768.973ce32e15099a48.js +0 -10
- package/dist/client/792.2e48eab4767d662a.js +0 -10
- package/dist/client/820.6a26239ea96c075a.js +0 -10
- package/dist/client/927.ff5cd05b14901ae6.js +0 -10
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["792"],{4281:function(e,t,r){r.d(t,{w:function(){return x},Rs:function(){return P},Cy:function(){return S}});var n=r(9155),o=r.n(n),l=r(2059),a=r(7375),c=r(3342),i=r(3079),u=r(8680),s=r(7694),p=r(7546),f=r(7596);function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function b(e,t){if(null==e)return{};var r,n,o,l={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,t){if(null==e)return{};var r,n,o={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)r=l[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}var g=(0,c.lazy)(function(){return Promise.all([r.e("428"),r.e("758")]).then(r.bind(r,2733))},"CodeHighlight").CodeHighlight,d=function(e){var t=e.language,r=e.value,n=e.height,l=e.scrollToBottom,a=b(e,["language","value","height","scrollToBottom"]);return o().createElement(g,y(m({},a),{language:t,value:r,height:n,scrollToBottom:l}))},O=function(e){var t=(0,s.useFlowContext)(),r=(0,i.kj)(),n=f.J.use.currentConversation(),c=(0,p.Y)(n),u=e.children,g=e.className,O=(e.node,e.message),h=b(e,["children","className","node","message"]),j=/language-(\w+)/.exec(g||""),w=j?j[1]:"",E=String(u).replace(/<!--[\s\S]*?-->/g,"").replace(/\n$/,""),P=l.App.useApp().message,x=!0;(null==O?void 0:O.type)==="text"&&(x=RegExp("```"+w+"[\\s\\S]*?```","s").test(O.content));var S=c.use.editorRef()[c.use.currentEditorRefUid()];return j?o().createElement(l.Card,{type:"inner",size:"small",title:o().createElement(l.Space,{style:{margin:"0 8px"},size:"middle"},o().createElement(a.CodeOutlined,null),o().createElement("span",null,w)),extra:o().createElement(o().Fragment,null,o().createElement(l.Tooltip,{title:r("Copy")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.CopyOutlined,null),onClick:function(){navigator.clipboard.writeText(E),P.success(r("Copied"))}})),o().createElement(l.Divider,{type:"vertical"}),o().createElement(l.Tooltip,{title:r("Expand")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.ExpandOutlined,null),onClick:function(){t.viewer.dialog({width:"80%",zIndex:6e3,content:o().createElement(v,y(m({},h),{language:w,value:E,height:"75vh"}))})}}))),styles:{header:{padding:0},body:{padding:0}},actions:S?[o().createElement(l.Button,{key:"accept",type:"link",onClick:function(e){e.stopPropagation(),null==S||S.write(E),t.message.info(r("Applied"))},disabled:!x},r("Apply to editor"))]:[]},o().createElement(d,y(m({},h),{language:w,value:E,scrollToBottom:!x}))):o().createElement(l.Typography.Text,y(m({code:!0},h),{className:g}),u)},v=function(e){var t=e.language,r=e.value,n=b(e,["language","value"]),c=(0,s.useFlowViewContext)(),i=c.view.Header,u=o().createElement(l.Button,{type:"text",icon:o().createElement(a.CloseOutlined,null),onClick:function(){c.view.close()}});return o().createElement("div",{style:{borderRadius:8}},o().createElement(i,{title:o().createElement(o().Fragment,null,o().createElement(l.Space,null,u,o().createElement("span",null,t)))}),o().createElement(d,y(m({},n),{language:t,value:r})))};function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function w(e,t){if(null==e)return{};var r,n,o,l={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,t){if(null==e)return{};var r,n,o={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)r=l[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}var E=(0,c.lazy)(function(){return Promise.all([r.e("428"),r.e("758")]).then(r.bind(r,2733))},"CodeHighlight").CodeHighlight,P=function(e){var t=e.language,r=e.value,n=w(e,["language","value"]);return o().createElement(E,j(h({},n),{language:t,value:r}))},x=function(e){var t=e.children,r=e.className,n=(e.node,e.message,w(e,["children","className","node","message"])),u=/language-(\w+)/.exec(r||""),s=u?u[1]:"",p=(0,c.useToken)().token,f=(0,i.kj)(),m=String(t).replace(/\n$/,""),y=l.App.useApp().message;return u?o().createElement(l.Card,{size:"small",title:s,styles:{title:{fontSize:p.fontSize,fontWeight:400},body:{width:"100%",fontSize:p.fontSizeSM}},extra:o().createElement(l.Button,{variant:"link",color:"default",size:"small",onClick:function(){navigator.clipboard.writeText(m),y.success(f("Copied"))},icon:o().createElement(a.CopyOutlined,null)})},o().createElement(P,j(h({},n),{language:s,value:m}))):o().createElement(l.Typography.Text,j(h({code:!0},n),{className:r}),t)},S=function(e){var t=e.className,r=/language-(\w+)/.exec(t||""),n=r?r[1]:"",l=f.J.use.currentConversation(),a=(0,p.Y)(l);return a.use.editorRef()[a.use.currentEditorRefUid()]&&(0,u._t)(n)?o().createElement(O,e):o().createElement(x,e)}},3002:function(e,t,r){r.d(t,{z:function(){return i}});var n=r(9155),o=r.n(n),l=r(2059),a=r(3079),c=r(3342),i=function(){var e=(0,a.kj)(),t=(0,c.useToken)().token;return o().createElement(o().Fragment,null,o().createElement(l.Spin,null),o().createElement("span",{style:{color:t.colorTextDescription,fontStyle:"italic",marginLeft:"8px"}},e("Generating")))}},931:function(e,t,r){r.r(t),r.d(t,{Markdown:function(){return T}});var n=r(9155),o=r.n(n),l=r(9597),a=r(5477),c=r(7916),i=r(1210),u=r(9256),s=r(1465),p=r(3342),f=r(4281),m=r(166),y=r(9452),b=r(3079),g=r(3002),d=r(2059),O=r(7596),v=r(7546),h=r(7821);function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function w(e,t,r,n,o,l,a){try{var c=e[l](a),i=c.value}catch(e){r(e);return}c.done?t(i):Promise.resolve(i).then(n,o)}function E(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var l=e.apply(t,r);function a(e){w(l,n,o,a,c,"next",e)}function c(e){w(l,n,o,a,c,"throw",e)}a(void 0)})}}function P(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e,t){var r,n,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:i(0)}),c(a,"throw",{value:i(1)}),c(a,"return",{value:i(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function i(c){return function(i){var u=[c,i];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(l=0)),l;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){l.label=u[1];break}if(6===u[0]&&l.label<o[1]){l.label=o[1],o=u;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(u);break}o[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var S=function(e){var t,r,l,a,c=(0,b.kj)();h.I.use.currentEmployee();var i=O.J.use.currentConversation(),u=(0,v.Y)(i).use.responseLoading(),s=e.children,w=e.node,S=e.message,k=w.properties,C=k.uid,A=k.datasource,I=k.collection,z=(0,n.useMemo)(function(){return{}},[null]),T=String(s).replace(/\n$/,""),D=function(e){if(Array.isArray(e))return e}(t=(0,n.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return j(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return j(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),R=D[0],N=D[1],F=!1;try{a=JSON.parse(T)}catch(e){F=!0}var B=(0,n.useMemo)(function(){return(0,y.createForm)({initialValues:a})},[a]);if(u&&!S.messageId)return o().createElement(g.z,null);if(F)return o().createElement(d.Alert,{type:"warning",message:o().createElement(o().Fragment,null,c("The current result is not a valid form object. Please ask the AI employee to regenerate it."),o().createElement(f.Rs,{language:"json",value:T})),style:{marginBottom:"16px"}});var _=Object.keys(a).reduce(function(e,t){var r,n,o;return e[t]={type:(null==(r=z[t])?void 0:r.type)||"string","x-decorator":"FormItem","x-component":"CollectionField","x-component-props":(null==(n=z[t])?void 0:n["x-component-props"])||{},"x-collection-field":null==(o=z[t])?void 0:o["x-collection-field"],"x-read-pretty":!R},e},{});return o().createElement("div",{style:{marginBottom:"16px"}},o().createElement(p.SchemaComponent,{schema:{type:"void",name:(0,m.uid)(),properties:P({},(0,m.uid)(),{type:"void","x-component":"FormBlockProvider","x-component-props":{collection:I,dataSource:A},properties:{form:{"x-component":"FormV2","x-component-props":{form:B},properties:(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){P(e,t,r[t])})}return e}({},_),l=l={fillOut:{type:"void","x-component":"Action",title:c("Fill out"),"x-component-props":{icon:"FormOutlined",variant:"outlined",color:"primary",size:"small",onClick:function(){return E(function(){return x(this,function(e){switch(e.label){case 0:return[4,B.submit()];case 1:return e.sent(),[2]}})})()}}},edit:{type:"void","x-component":"Action",title:c(R?"Save":"Edit"),"x-component-props":{style:{marginLeft:"8px"},icon:R?"SaveOutlined":"EditOutlined",variant:"outlined",size:"small",onClick:function(){return E(function(){return x(this,function(e){var t,r,n;return R?(t=S.content,r=JSON.stringify(B.values),n=RegExp("<form\\b[^>]*\\buid=[\"']".concat(C,"[\"'][^>]*>([\\s\\S]*?)<\\/form>"),"gi"),t.replace(n,function(e,t){return e.replace(t,r)}),[2]):(N(!R),[2])})})()}}},cancel:{type:"void","x-component":"Action",title:c("Cancel"),"x-display":R?"visible":"hidden","x-component-props":{style:{marginLeft:"8px"},icon:"CloseOutlined",variant:"outlined",size:"small",onClick:function(){N(!1),B.reset()}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(l)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(l)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(l,e))}),r)}}})}}))};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function A(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function I(){var e,t,r=(e=["\n margin-bottom: -1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return I=function(){return r},r}var z=(0,p.lazy)(function(){return Promise.all([r.e("502"),r.e("428"),r.e("832"),r.e("711")]).then(r.bind(r,602))},"Echarts").Echarts,T=o().memo(function(e){var t,r=e.message,n={};return o().createElement("div",{className:(0,a.css)(I())},o().createElement(l.oz,{components:{code:function(e){return o().createElement(f.Cy,A(C({},e),{message:r}))},form:function(e){return o().createElement(S,A(C({},e),{message:r}))},echarts:function(e){var t;return o().createElement(z,A(C({},e),{index:((t="echarts")in n||(n[t]=-1),++n[t]),message:r}))}},rehypePlugins:[i.A,[u.A,A(C({},s.j),{tagNames:((function(e){if(Array.isArray(e))return k(e)})(t=s.j.tagNames)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return k(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return k(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["echarts","form","collections"]),attributes:A(C({},s.j.attributes),{form:["uid","datasource","collection"]})})]],remarkPlugins:[c.A]},r.content))},function(e,t){var r,n,o,l;return(null==(r=e.message)?void 0:r.messageId)===(null==(n=t.message)?void 0:n.messageId)&&(null==(o=e.message)?void 0:o.content)===(null==(l=t.message)?void 0:l.content)})}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["820"],{5823:function(e,n,t){t.r(n),t.d(n,{DataModelingCard:function(){return d}});var l=t(9155),a=t.n(l),o=t(2059),r=t(7375),i=t(3079),s=t(3342),c=t(107),u=t(7546),m=t(7596),d=function(e){var n,t,l,d=e.messageId,g=e.toolCall,p=(0,i.kj)(),f=(0,s.useToken)().token,E=m.J.use.currentConversation(),v=(0,u.Y)(E),C=v.use.responseLoading(),k=v.use.messages(),y=c.y.use.setOpenToolModal(),h=c.y.use.setActiveTool(),T=c.y.use.setActiveMessageId(),b=null==(t=c.y.use.toolsByMessageId()[d])||null==(n=t[g.id])?void 0:n.version,I=C&&(null==(l=k[length-1])?void 0:l.content.messageId)===d,_=a().createElement(a().Fragment,null,p("Please review and finish the process"));return I?_=a().createElement(a().Fragment,null,a().createElement(o.Spin,{indicator:a().createElement(r.LoadingOutlined,{spin:!0}),size:"small"})," ",p("Generating...")):g.args.collections||(console.error("Invalid definition",g.args),_=a().createElement(a().Fragment,null,a().createElement(r.ExclamationCircleTwoTone,{twoToneColor:"#eb2f96"})," ",p("Invalid definition"))),a().createElement(a().Fragment,null,a().createElement(o.Card,{style:{margin:"16px 0",cursor:"pointer"},onClick:function(){!I&&g.args.collections&&(h(g),T(d),y(!0))}},a().createElement(o.Card.Meta,{avatar:a().createElement(r.DatabaseOutlined,null),title:a().createElement(a().Fragment,null,p("Data modeling"),b&&b>1?a().createElement("span",{style:{marginLeft:"8px",color:f.colorTextDescription,fontWeight:"normal",fontStyle:"italic"}},p("Version")," ",b):null),description:_})))}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["927"],{9266:function(e,t,n){n.r(t),n.d(t,{SubAgentDispatchCard:function(){return m}});var r=n(9155),o=n.n(r),l=n(2059),a=n(7375),i=n(3342),c=n(7694),u=n(3079),s=n(7330),d=n(9929),p=n(7546),y=n(7596);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var m=(0,c.observer)(function(e){var t,n,c,m,v=e.messageId,h=e.toolCall;(0,u.kj)();var b=(0,i.useToken)().token,S=(0,s.M)(),x=y.J.use.currentConversation(),E=(0,p.Y)(x),k=E.use.responseLoading(),T=E.use.messages(),A=function(e){if(Array.isArray(e))return e}(t=(0,r.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return f(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return f(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),w=A[0],z=A[1];(0,r.useEffect)(function(){S.getAIEmployees()},[S]);var C=T[T.length-1],I=k&&(null==C||null==(n=C.content)?void 0:n.messageId)===v,j="string"==typeof(null==(c=h.args)?void 0:c.username)?h.args.username:"",F="string"==typeof(null==(m=h.args)?void 0:m.question)?h.args.question:"",O=g(S.aiEmployees,j),_=O.avatar?(0,d.H)(O.avatar):void 0,M=!!F,R=function(){M&&z(function(e){return!e})};return o().createElement("div",{onClick:R,onKeyDown:function(e){M&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),R())},role:M?"button":void 0,tabIndex:M?0:void 0,"aria-expanded":M?w:void 0,style:{margin:"8px 0",padding:"6px 10px",borderRadius:b.borderRadiusLG,background:b.colorFillTertiary,cursor:M?"pointer":"default"}},o().createElement(l.Flex,{align:"center",justify:"space-between",gap:8},o().createElement(l.Flex,{align:"center",gap:8,style:{minWidth:0,flex:1}},o().createElement(l.Avatar,{size:28,src:_,icon:_?void 0:o().createElement(a.RobotOutlined,null),style:{flexShrink:0,background:_?void 0:b.colorFillSecondary,color:b.colorTextSecondary}}),o().createElement(l.Flex,{vertical:!0,gap:0,style:{minWidth:0,flex:1}},o().createElement(l.Typography.Text,{strong:!0,ellipsis:!0,style:{color:b.colorText,fontSize:b.fontSizeSM+1,minWidth:0}},"@".concat(O.nickname)),O.position?o().createElement(l.Typography.Text,{type:"secondary",ellipsis:!0,style:{fontSize:b.fontSizeSM,minWidth:0,lineHeight:1.4}},O.position):null)),o().createElement(l.Flex,{align:"center",gap:4},I?o().createElement(l.Spin,{indicator:o().createElement(a.LoadingOutlined,{spin:!0}),size:"small"}):null,M?o().createElement("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",color:b.colorTextTertiary}},w?o().createElement(a.UpOutlined,null):o().createElement(a.RightOutlined,null)):null)),w&&F?o().createElement("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid ".concat(b.colorBorderSecondary)}},o().createElement(l.Typography.Text,{type:"secondary",style:{display:"block",fontSize:b.fontSizeSM,whiteSpace:"pre-wrap"}},F)):null)}),g=function(e,t){var n=t||"",r=null==e?void 0:e.find(function(e){return e.username===n});return{username:n,nickname:(null==r?void 0:r.nickname)||n,position:null==r?void 0:r.position,avatar:null==r?void 0:r.avatar,matched:!!r}}}}]);
|
|
@@ -8,20 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { ModelRef } from '../stores/chat-box';
|
|
11
|
-
type UseConversationsListOptions = {
|
|
12
|
-
onOpenConversation: (sessionId: string, username?: string, model?: ModelRef) => void;
|
|
13
|
-
};
|
|
14
|
-
export declare const useConversationsList: ({ onOpenConversation }: UseConversationsListOptions) => {
|
|
15
|
-
currentConversation: string;
|
|
16
|
-
items: import("@ant-design/x/es/conversations").Conversation[];
|
|
17
|
-
onSelectConversation: (sessionId: string) => void;
|
|
18
|
-
attachLastConversationObserver: (container: HTMLDivElement | null) => void;
|
|
19
|
-
openDeleteConfirm: (sessionId: string) => void;
|
|
20
|
-
runSearch: (keyword?: string) => void;
|
|
21
|
-
refresh: () => void;
|
|
22
|
-
};
|
|
23
|
-
export type ConversationsListController = ReturnType<typeof useConversationsList>;
|
|
24
11
|
export declare const ConversationsList: React.FC<{
|
|
25
|
-
|
|
12
|
+
onOpenConversation: (sessionId: string, username?: string, model?: ModelRef) => void;
|
|
26
13
|
}>;
|
|
27
|
-
export {};
|
|
@@ -8,26 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { ModelRef } from '../stores/chat-box';
|
|
11
|
-
type UseWorkflowTasksListOptions = {
|
|
12
|
-
onOpenConversation: (sessionId: string, username?: string, model?: ModelRef) => void;
|
|
13
|
-
};
|
|
14
|
-
export declare const useWorkflowTasksList: ({ onOpenConversation }: UseWorkflowTasksListOptions) => {
|
|
15
|
-
currentConversation: string;
|
|
16
|
-
selectedConversation: string;
|
|
17
|
-
loading: boolean;
|
|
18
|
-
workflowTasks: import("./common").WorkflowTask[];
|
|
19
|
-
unreadCount: number;
|
|
20
|
-
selectedJobStatus: number;
|
|
21
|
-
onSelectWorkflowTask: (sessionId: string) => Promise<void>;
|
|
22
|
-
runSearch: (nextKeyword?: string) => void;
|
|
23
|
-
runJobStatusFilter: (nextJobStatus?: number) => void;
|
|
24
|
-
refresh: () => void;
|
|
25
|
-
hasMore: boolean;
|
|
26
|
-
loadMoreWorkflowTasks: () => Promise<void>;
|
|
27
|
-
lastWorkflowTaskRef: (node: HTMLElement) => void;
|
|
28
|
-
};
|
|
29
|
-
export type WorkflowTasksListController = ReturnType<typeof useWorkflowTasksList>;
|
|
30
11
|
export declare const WorkflowTasksList: React.FC<{
|
|
31
|
-
|
|
12
|
+
onOpenConversation: (sessionId: string, username?: string, model?: ModelRef) => void;
|
|
32
13
|
}>;
|
|
33
|
-
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { EditorRef } from '@nocobase/client';
|
|
10
|
+
import { Attachment, ContextItem, Message, SkillSettings, WebSearching } from '../../types';
|
|
11
|
+
import { ChatSessionState } from '../stores/chat-messages';
|
|
12
|
+
type MessagesMeta = ChatSessionState['messagesMeta'];
|
|
13
|
+
export declare const useChat: (sessionId?: string) => {
|
|
14
|
+
use: {
|
|
15
|
+
messages: () => Message[];
|
|
16
|
+
messagesLoading: () => boolean;
|
|
17
|
+
messagesError: () => any;
|
|
18
|
+
messagesMeta: () => {
|
|
19
|
+
cursor?: string;
|
|
20
|
+
hasMore?: boolean;
|
|
21
|
+
};
|
|
22
|
+
attachments: () => any[];
|
|
23
|
+
contextItems: () => ContextItem[];
|
|
24
|
+
systemMessage: () => string;
|
|
25
|
+
responseLoading: () => boolean;
|
|
26
|
+
backgroundWorking: () => boolean;
|
|
27
|
+
resumeStreamFailed: () => boolean;
|
|
28
|
+
abortController: () => AbortController;
|
|
29
|
+
skillSettings: () => SkillSettings;
|
|
30
|
+
webSearching: () => WebSearching;
|
|
31
|
+
editorRef: () => Record<string, EditorRef>;
|
|
32
|
+
currentEditorRefUid: () => string;
|
|
33
|
+
flowContext: () => any;
|
|
34
|
+
};
|
|
35
|
+
getState: () => {
|
|
36
|
+
setMessages: (messages: Message[] | ((prev: Message[]) => Message[])) => void;
|
|
37
|
+
setMessagesLoading: (loading: boolean) => void;
|
|
38
|
+
setMessagesError: (error: any) => void;
|
|
39
|
+
setMessagesMeta: (meta: {
|
|
40
|
+
cursor?: string;
|
|
41
|
+
hasMore?: boolean;
|
|
42
|
+
} | ((prev: MessagesMeta) => MessagesMeta)) => void;
|
|
43
|
+
setAttachments: (attachments: any[] | ((prev: Attachment[]) => Attachment[])) => void;
|
|
44
|
+
setContextItems: (items: ContextItem[] | ((prev: ContextItem[]) => ContextItem[])) => void;
|
|
45
|
+
setSystemMessage: (msg: string | ((prev: string) => string)) => void;
|
|
46
|
+
setResponseLoading: (loading: boolean) => void;
|
|
47
|
+
setBackgroundWorking: (backgroundWorking: boolean) => void;
|
|
48
|
+
setResumeStreamFailed: (resumeStreamFailed: boolean) => void;
|
|
49
|
+
addMessage: (msg: Message) => void;
|
|
50
|
+
addMessages: (msgs: Message[]) => void;
|
|
51
|
+
updateLastMessage: (updater: (msg: Message) => Message) => void;
|
|
52
|
+
removeMessage: (key: string) => void;
|
|
53
|
+
addAttachments: (attachments: Attachment | Attachment[]) => void;
|
|
54
|
+
removeAttachment: (filename: string) => void;
|
|
55
|
+
addContextItems: (items: ContextItem | ContextItem[]) => void;
|
|
56
|
+
removeContextItem: (type: string, uid: string) => void;
|
|
57
|
+
setAbortController: (controller: AbortController | undefined) => void;
|
|
58
|
+
setSkillSettings: (settings: SkillSettings | undefined) => void;
|
|
59
|
+
setWebSearching: (webSearching: WebSearching) => void;
|
|
60
|
+
addSubAgentMessage: (subSessionId: string, msg: Message) => void;
|
|
61
|
+
addSubAgentMessages: (subSessionId: string, msgs: Message[]) => void;
|
|
62
|
+
updateLastSubAgentMessage: (subSessionId: string, username: string, updater: (msg: Message) => Message) => void;
|
|
63
|
+
updateSubAgentConversationStatus: (subSessionId: string, status: 'pending' | 'completed') => void;
|
|
64
|
+
setEditorRef: (uid: string, editorRef: EditorRef) => void;
|
|
65
|
+
setCurrentEditorRefUid: (uid: string) => void;
|
|
66
|
+
setFlowContext: (flowContext: any) => void;
|
|
67
|
+
migrateSessionState: (toSessionId: string) => void;
|
|
68
|
+
resetSessionState: (patch?: Partial<ChatSessionState>) => void;
|
|
69
|
+
editorRef: Record<string, EditorRef>;
|
|
70
|
+
currentEditorRefUid: string;
|
|
71
|
+
flowContext: any;
|
|
72
|
+
messages: Message[];
|
|
73
|
+
messagesLoading: boolean;
|
|
74
|
+
messagesError?: any;
|
|
75
|
+
messagesMeta: {
|
|
76
|
+
cursor?: string;
|
|
77
|
+
hasMore?: boolean;
|
|
78
|
+
};
|
|
79
|
+
attachments: any[];
|
|
80
|
+
contextItems: ContextItem[];
|
|
81
|
+
systemMessage: string;
|
|
82
|
+
responseLoading: boolean;
|
|
83
|
+
abortController?: AbortController;
|
|
84
|
+
skillSettings?: SkillSettings;
|
|
85
|
+
webSearching?: WebSearching;
|
|
86
|
+
backgroundWorking: boolean;
|
|
87
|
+
resumeStreamFailed: boolean;
|
|
88
|
+
};
|
|
89
|
+
setMessages: (messages: Message[] | ((prev: Message[]) => Message[])) => void;
|
|
90
|
+
setMessagesLoading: (loading: boolean) => void;
|
|
91
|
+
setMessagesError: (error: any) => void;
|
|
92
|
+
setMessagesMeta: (meta: {
|
|
93
|
+
cursor?: string;
|
|
94
|
+
hasMore?: boolean;
|
|
95
|
+
} | ((prev: MessagesMeta) => MessagesMeta)) => void;
|
|
96
|
+
setAttachments: (attachments: any[] | ((prev: Attachment[]) => Attachment[])) => void;
|
|
97
|
+
setContextItems: (items: ContextItem[] | ((prev: ContextItem[]) => ContextItem[])) => void;
|
|
98
|
+
setSystemMessage: (msg: string | ((prev: string) => string)) => void;
|
|
99
|
+
setResponseLoading: (loading: boolean) => void;
|
|
100
|
+
setBackgroundWorking: (backgroundWorking: boolean) => void;
|
|
101
|
+
setResumeStreamFailed: (resumeStreamFailed: boolean) => void;
|
|
102
|
+
addMessage: (msg: Message) => void;
|
|
103
|
+
addMessages: (msgs: Message[]) => void;
|
|
104
|
+
updateLastMessage: (updater: (msg: Message) => Message) => void;
|
|
105
|
+
removeMessage: (key: string) => void;
|
|
106
|
+
addAttachments: (attachments: Attachment | Attachment[]) => void;
|
|
107
|
+
removeAttachment: (filename: string) => void;
|
|
108
|
+
addContextItems: (items: ContextItem | ContextItem[]) => void;
|
|
109
|
+
removeContextItem: (type: string, uid: string) => void;
|
|
110
|
+
setAbortController: (controller: AbortController | undefined) => void;
|
|
111
|
+
setSkillSettings: (settings: SkillSettings | undefined) => void;
|
|
112
|
+
setWebSearching: (webSearching: WebSearching) => void;
|
|
113
|
+
addSubAgentMessage: (subSessionId: string, msg: Message) => void;
|
|
114
|
+
addSubAgentMessages: (subSessionId: string, msgs: Message[]) => void;
|
|
115
|
+
updateLastSubAgentMessage: (subSessionId: string, username: string, updater: (msg: Message) => Message) => void;
|
|
116
|
+
updateSubAgentConversationStatus: (subSessionId: string, status: 'pending' | 'completed') => void;
|
|
117
|
+
setEditorRef: (uid: string, editorRef: EditorRef) => void;
|
|
118
|
+
setCurrentEditorRefUid: (uid: string) => void;
|
|
119
|
+
setFlowContext: (flowContext: any) => void;
|
|
120
|
+
migrateSessionState: (toSessionId: string) => void;
|
|
121
|
+
resetSessionState: (patch?: Partial<ChatSessionState>) => void;
|
|
122
|
+
sessionKey: string;
|
|
123
|
+
for: (targetSessionId?: string) => any;
|
|
124
|
+
};
|
|
125
|
+
export {};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AIEmployee, ClearOptions, SendOptions, TriggerTaskOptions } from '../../types';
|
|
10
10
|
export declare const useChatBoxActions: () => {
|
|
11
|
-
clear: (options?: ClearOptions) => void;
|
|
11
|
+
clear: (options?: ClearOptions, sessionId?: string | undefined) => void;
|
|
12
12
|
send: (options: SendOptions) => void;
|
|
13
13
|
startNewConversation: () => void;
|
|
14
14
|
switchAIEmployee: (aiEmployee: AIEmployee, options?: {
|
|
@@ -8,6 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Conversation } from '../../types';
|
|
10
10
|
export declare const useChatConversationActions: () => {
|
|
11
|
-
conversationsService: import("@nocobase/client").UseRequestResult<
|
|
11
|
+
conversationsService: import("@nocobase/client").UseRequestResult<{
|
|
12
|
+
data: Conversation[];
|
|
13
|
+
meta: {
|
|
14
|
+
count: number;
|
|
15
|
+
page: number;
|
|
16
|
+
pageSize: number;
|
|
17
|
+
totalPage: number;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
loadUnreadCounts: () => Promise<void>;
|
|
12
21
|
lastConversationRef: (node: HTMLElement) => void;
|
|
22
|
+
runSearch: (keyword?: string) => void;
|
|
23
|
+
refresh: () => void;
|
|
24
|
+
unreadCount: number;
|
|
13
25
|
};
|
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import { AIEmployee,
|
|
9
|
+
import { AIEmployee, ResendOptions, SendOptions } from '../../types';
|
|
10
10
|
import { ContextItem } from '../../types';
|
|
11
11
|
export declare const useChatMessageActions: () => {
|
|
12
12
|
syncContextAttachments: (items: ContextItem | ContextItem[]) => void;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
meta: {
|
|
16
|
-
cursor?: string;
|
|
17
|
-
hasMore?: boolean;
|
|
18
|
-
};
|
|
19
|
-
}>;
|
|
13
|
+
loadMessages: (sessionId?: string, cursor?: string) => Promise<void>;
|
|
14
|
+
loadMoreMessages: () => Promise<void>;
|
|
20
15
|
sendMessages: ({ sessionId, aiEmployee, systemMessage, messages: sendMsgs, attachments, workContext, editingMessageId, onConversationCreate, skillSettings, webSearch, model: inputModel, }: SendOptions & {
|
|
21
16
|
onConversationCreate?: (sessionId: string) => void;
|
|
22
17
|
}) => Promise<void>;
|
|
23
18
|
resendMessages: ({ sessionId, messageId, aiEmployee, important }: ResendOptions) => Promise<void>;
|
|
19
|
+
resumeStream: ({ sessionId, aiEmployee }: {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
aiEmployee: AIEmployee;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
getConversationLLMActiveState: (sessionId: string) => Promise<string | undefined>;
|
|
24
24
|
cancelRequest: () => Promise<void>;
|
|
25
25
|
resumeToolCall: ({ sessionId, messageId, aiEmployee, toolCallIds, toolCallResults, }: {
|
|
26
26
|
sessionId: string;
|
|
@@ -13,6 +13,7 @@ interface ChatConversationsState {
|
|
|
13
13
|
keyword: string;
|
|
14
14
|
webSearch: boolean;
|
|
15
15
|
conversationSegmented: string;
|
|
16
|
+
unreadCount: number;
|
|
16
17
|
}
|
|
17
18
|
interface ChatConversationsActions {
|
|
18
19
|
setCurrentConversation: (id: string | undefined) => void;
|
|
@@ -20,6 +21,7 @@ interface ChatConversationsActions {
|
|
|
20
21
|
setConversations: (conversations: Conversation[] | ((prev: Conversation[]) => Conversation[])) => void;
|
|
21
22
|
setWebSearch: (webSearch: boolean) => void;
|
|
22
23
|
setConversationSegmented: (conversationSegmented: string) => void;
|
|
24
|
+
setUnreadCount: (unreadCount: number | ((prev: number) => number)) => void;
|
|
23
25
|
}
|
|
24
26
|
export declare const useChatConversationsStore: {
|
|
25
27
|
(): ChatConversationsState & ChatConversationsActions;
|
|
@@ -31,11 +33,13 @@ export declare const useChatConversationsStore: {
|
|
|
31
33
|
keyword: () => string;
|
|
32
34
|
webSearch: () => boolean;
|
|
33
35
|
conversationSegmented: () => string;
|
|
36
|
+
unreadCount: () => number;
|
|
34
37
|
setCurrentConversation: () => (id: string | undefined) => void;
|
|
35
38
|
setKeyword: () => (keyword: string) => void;
|
|
36
39
|
setConversations: () => (conversations: Conversation[] | ((prev: Conversation[]) => Conversation[])) => void;
|
|
37
40
|
setWebSearch: () => (webSearch: boolean) => void;
|
|
38
41
|
setConversationSegmented: () => (conversationSegmented: string) => void;
|
|
42
|
+
setUnreadCount: () => (unreadCount: number | ((prev: number) => number)) => void;
|
|
39
43
|
};
|
|
40
44
|
};
|
|
41
45
|
export {};
|
|
@@ -8,83 +8,110 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Message, Attachment, ContextItem, SkillSettings, WebSearching } from '../../types';
|
|
10
10
|
import { EditorRef } from '@nocobase/client';
|
|
11
|
-
|
|
11
|
+
export declare const CHAT_DEFAULT_SESSION_KEY = "__draft__";
|
|
12
|
+
export declare const getChatSessionKey: (sessionId?: string) => string;
|
|
13
|
+
export type ChatSessionState = {
|
|
12
14
|
messages: Message[];
|
|
15
|
+
messagesLoading: boolean;
|
|
16
|
+
messagesError?: any;
|
|
17
|
+
messagesMeta: {
|
|
18
|
+
cursor?: string;
|
|
19
|
+
hasMore?: boolean;
|
|
20
|
+
};
|
|
13
21
|
attachments: Attachment[];
|
|
14
22
|
contextItems: ContextItem[];
|
|
15
23
|
systemMessage: string;
|
|
16
24
|
responseLoading: boolean;
|
|
17
25
|
abortController?: AbortController;
|
|
18
26
|
skillSettings?: SkillSettings;
|
|
27
|
+
webSearching?: WebSearching;
|
|
28
|
+
backgroundWorking: boolean;
|
|
29
|
+
resumeStreamFailed: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const CHAT_EMPTY_SESSION_STATE: ChatSessionState;
|
|
32
|
+
type ChatMessagesState = {
|
|
33
|
+
sessions: Record<string, ChatSessionState>;
|
|
19
34
|
editorRef?: Record<string, EditorRef>;
|
|
20
35
|
currentEditorRefUid?: string;
|
|
21
|
-
webSearching?: WebSearching;
|
|
22
36
|
flowContext?: any;
|
|
23
37
|
};
|
|
38
|
+
type SessionStateUpdater<T> = T | ((prev: T) => T);
|
|
24
39
|
export interface ChatMessagesActions {
|
|
25
|
-
setMessages: (messages: Message[] | ((prev: Message[]) => Message[])) => void;
|
|
26
|
-
setAttachments: (attachments: Attachment[] | ((prev: Attachment[]) => Attachment[])) => void;
|
|
27
|
-
setContextItems: (items: ContextItem[] | ((prev: ContextItem[]) => ContextItem[])) => void;
|
|
28
|
-
setSystemMessage: (msg: string | ((prev: string) => string)) => void;
|
|
29
|
-
setResponseLoading: (loading: boolean) => void;
|
|
30
|
-
addMessage: (msg: Message) => void;
|
|
31
|
-
addMessages: (msgs: Message[]) => void;
|
|
32
|
-
updateLastMessage: (updater: (msg: Message) => Message) => void;
|
|
33
|
-
removeMessage: (key: string) => void;
|
|
34
|
-
addAttachments: (attachments: Attachment | Attachment[]) => void;
|
|
35
|
-
removeAttachment: (filename: string) => void;
|
|
36
|
-
addContextItems: (items: ContextItem | ContextItem[]) => void;
|
|
37
|
-
removeContextItem: (type: string, uid: string) => void;
|
|
38
|
-
setAbortController: (controller: AbortController | undefined) => void;
|
|
39
|
-
setSkillSettings: (settings: SkillSettings | undefined) => void;
|
|
40
40
|
setEditorRef: (uid: string, editorRef: EditorRef) => void;
|
|
41
41
|
setCurrentEditorRefUid: (uid: string) => void;
|
|
42
|
-
setWebSearching: (webSearching: WebSearching) => void;
|
|
43
42
|
setFlowContext: (ctx: any) => void;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
getSessionState: (sessionId?: string) => ChatSessionState;
|
|
44
|
+
resetSessionState: (sessionId?: string, patch?: Partial<ChatSessionState>) => void;
|
|
45
|
+
migrateSessionState: (fromSessionId: string | undefined, toSessionId: string) => void;
|
|
46
|
+
setSessionMessages: (sessionId: string | undefined, messages: SessionStateUpdater<Message[]>) => void;
|
|
47
|
+
setSessionMessagesLoading: (sessionId: string | undefined, loading: boolean) => void;
|
|
48
|
+
setSessionMessagesError: (sessionId: string | undefined, error: any) => void;
|
|
49
|
+
setSessionMessagesMeta: (sessionId: string | undefined, meta: ChatSessionState['messagesMeta'] | ((prev: ChatSessionState['messagesMeta']) => ChatSessionState['messagesMeta'])) => void;
|
|
50
|
+
setSessionAttachments: (sessionId: string | undefined, attachments: SessionStateUpdater<Attachment[]>) => void;
|
|
51
|
+
setSessionContextItems: (sessionId: string | undefined, items: SessionStateUpdater<ContextItem[]>) => void;
|
|
52
|
+
setSessionSystemMessage: (sessionId: string | undefined, msg: string | ((prev: string) => string)) => void;
|
|
53
|
+
setSessionResponseLoading: (sessionId: string | undefined, loading: boolean) => void;
|
|
54
|
+
setSessionBackgroundWorking: (sessionId: string | undefined, backgroundWorking: boolean) => void;
|
|
55
|
+
setSessionResumeStreamFailed: (sessionId: string | undefined, resumeStreamFailed: boolean) => void;
|
|
56
|
+
addSessionMessage: (sessionId: string | undefined, msg: Message) => void;
|
|
57
|
+
addSessionMessages: (sessionId: string | undefined, msgs: Message[]) => void;
|
|
58
|
+
updateSessionLastMessage: (sessionId: string | undefined, updater: (msg: Message) => Message) => void;
|
|
59
|
+
removeSessionMessage: (sessionId: string | undefined, key: string) => void;
|
|
60
|
+
addSessionAttachments: (sessionId: string | undefined, attachments: Attachment | Attachment[]) => void;
|
|
61
|
+
removeSessionAttachment: (sessionId: string | undefined, filename: string) => void;
|
|
62
|
+
addSessionContextItems: (sessionId: string | undefined, items: ContextItem | ContextItem[]) => void;
|
|
63
|
+
removeSessionContextItem: (sessionId: string | undefined, type: string, uid: string) => void;
|
|
64
|
+
setSessionAbortController: (sessionId: string | undefined, controller: AbortController | undefined) => void;
|
|
65
|
+
setSessionSkillSettings: (sessionId: string | undefined, settings: SkillSettings | undefined) => void;
|
|
66
|
+
setSessionWebSearching: (sessionId: string | undefined, webSearching: WebSearching) => void;
|
|
67
|
+
addSessionSubAgentMessage: (sessionId: string | undefined, subSessionId: string, msg: Message) => void;
|
|
68
|
+
addSessionSubAgentMessages: (sessionId: string | undefined, subSessionId: string, msgs: Message[]) => void;
|
|
69
|
+
updateSessionLastSubAgentMessage: (sessionId: string | undefined, subSessionId: string, username: string, updater: (msg: Message) => Message) => void;
|
|
70
|
+
updateSessionSubAgentConversationStatus: (sessionId: string | undefined, subSessionId: string, status: 'pending' | 'completed') => void;
|
|
48
71
|
}
|
|
49
72
|
export declare const useChatMessagesStore: {
|
|
50
73
|
(): ChatMessagesState & ChatMessagesActions;
|
|
51
74
|
<U>(selector: (state: ChatMessagesState & ChatMessagesActions) => U): U;
|
|
52
75
|
} & import("zustand").StoreApi<ChatMessagesState & ChatMessagesActions> & {
|
|
53
76
|
use: {
|
|
54
|
-
|
|
55
|
-
attachments: () => any[];
|
|
56
|
-
contextItems: () => ContextItem[];
|
|
57
|
-
systemMessage: () => string;
|
|
58
|
-
responseLoading: () => boolean;
|
|
59
|
-
abortController?: () => AbortController;
|
|
60
|
-
skillSettings?: () => SkillSettings;
|
|
77
|
+
sessions: () => Record<string, ChatSessionState>;
|
|
61
78
|
editorRef?: () => Record<string, EditorRef>;
|
|
62
79
|
currentEditorRefUid?: () => string;
|
|
63
|
-
webSearching?: () => WebSearching;
|
|
64
80
|
flowContext?: () => any;
|
|
65
|
-
setMessages: () => (messages: Message[] | ((prev: Message[]) => Message[])) => void;
|
|
66
|
-
setAttachments: () => (attachments: any[] | ((prev: Attachment[]) => Attachment[])) => void;
|
|
67
|
-
setContextItems: () => (items: ContextItem[] | ((prev: ContextItem[]) => ContextItem[])) => void;
|
|
68
|
-
setSystemMessage: () => (msg: string | ((prev: string) => string)) => void;
|
|
69
|
-
setResponseLoading: () => (loading: boolean) => void;
|
|
70
|
-
addMessage: () => (msg: Message) => void;
|
|
71
|
-
addMessages: () => (msgs: Message[]) => void;
|
|
72
|
-
updateLastMessage: () => (updater: (msg: Message) => Message) => void;
|
|
73
|
-
removeMessage: () => (key: string) => void;
|
|
74
|
-
addAttachments: () => (attachments: Attachment | Attachment[]) => void;
|
|
75
|
-
removeAttachment: () => (filename: string) => void;
|
|
76
|
-
addContextItems: () => (items: ContextItem | ContextItem[]) => void;
|
|
77
|
-
removeContextItem: () => (type: string, uid: string) => void;
|
|
78
|
-
setAbortController: () => (controller: AbortController | undefined) => void;
|
|
79
|
-
setSkillSettings: () => (settings: SkillSettings | undefined) => void;
|
|
80
81
|
setEditorRef: () => (uid: string, editorRef: EditorRef) => void;
|
|
81
82
|
setCurrentEditorRefUid: () => (uid: string) => void;
|
|
82
|
-
setWebSearching: () => (webSearching: WebSearching) => void;
|
|
83
83
|
setFlowContext: () => (ctx: any) => void;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
getSessionState: () => (sessionId?: string) => ChatSessionState;
|
|
85
|
+
resetSessionState: () => (sessionId?: string, patch?: Partial<ChatSessionState>) => void;
|
|
86
|
+
migrateSessionState: () => (fromSessionId: string | undefined, toSessionId: string) => void;
|
|
87
|
+
setSessionMessages: () => (sessionId: string | undefined, messages: SessionStateUpdater<Message[]>) => void;
|
|
88
|
+
setSessionMessagesLoading: () => (sessionId: string | undefined, loading: boolean) => void;
|
|
89
|
+
setSessionMessagesError: () => (sessionId: string | undefined, error: any) => void;
|
|
90
|
+
setSessionMessagesMeta: () => (sessionId: string | undefined, meta: {
|
|
91
|
+
cursor?: string;
|
|
92
|
+
hasMore?: boolean;
|
|
93
|
+
} | ((prev: ChatSessionState['messagesMeta']) => ChatSessionState['messagesMeta'])) => void;
|
|
94
|
+
setSessionAttachments: () => (sessionId: string | undefined, attachments: SessionStateUpdater<Attachment[]>) => void;
|
|
95
|
+
setSessionContextItems: () => (sessionId: string | undefined, items: SessionStateUpdater<ContextItem[]>) => void;
|
|
96
|
+
setSessionSystemMessage: () => (sessionId: string | undefined, msg: string | ((prev: string) => string)) => void;
|
|
97
|
+
setSessionResponseLoading: () => (sessionId: string | undefined, loading: boolean) => void;
|
|
98
|
+
setSessionBackgroundWorking: () => (sessionId: string | undefined, backgroundWorking: boolean) => void;
|
|
99
|
+
setSessionResumeStreamFailed: () => (sessionId: string | undefined, resumeStreamFailed: boolean) => void;
|
|
100
|
+
addSessionMessage: () => (sessionId: string | undefined, msg: Message) => void;
|
|
101
|
+
addSessionMessages: () => (sessionId: string | undefined, msgs: Message[]) => void;
|
|
102
|
+
updateSessionLastMessage: () => (sessionId: string | undefined, updater: (msg: Message) => Message) => void;
|
|
103
|
+
removeSessionMessage: () => (sessionId: string | undefined, key: string) => void;
|
|
104
|
+
addSessionAttachments: () => (sessionId: string | undefined, attachments: Attachment | Attachment[]) => void;
|
|
105
|
+
removeSessionAttachment: () => (sessionId: string | undefined, filename: string) => void;
|
|
106
|
+
addSessionContextItems: () => (sessionId: string | undefined, items: ContextItem | ContextItem[]) => void;
|
|
107
|
+
removeSessionContextItem: () => (sessionId: string | undefined, type: string, uid: string) => void;
|
|
108
|
+
setSessionAbortController: () => (sessionId: string | undefined, controller: AbortController | undefined) => void;
|
|
109
|
+
setSessionSkillSettings: () => (sessionId: string | undefined, settings: SkillSettings | undefined) => void;
|
|
110
|
+
setSessionWebSearching: () => (sessionId: string | undefined, webSearching: WebSearching) => void;
|
|
111
|
+
addSessionSubAgentMessage: () => (sessionId: string | undefined, subSessionId: string, msg: Message) => void;
|
|
112
|
+
addSessionSubAgentMessages: () => (sessionId: string | undefined, subSessionId: string, msgs: Message[]) => void;
|
|
113
|
+
updateSessionLastSubAgentMessage: () => (sessionId: string | undefined, subSessionId: string, username: string, updater: (msg: Message) => Message) => void;
|
|
114
|
+
updateSessionSubAgentConversationStatus: () => (sessionId: string | undefined, subSessionId: string, status: 'pending' | 'completed') => void;
|
|
88
115
|
};
|
|
89
116
|
};
|
|
90
117
|
export {};
|
|
@@ -6,31 +6,39 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
type ToolCallInvokeState = {
|
|
10
|
+
id: string;
|
|
11
|
+
invokeStatus: string;
|
|
12
|
+
};
|
|
13
|
+
export type ChatToolCallSessionState = {
|
|
14
|
+
toolCalls: Record<string, ToolCallInvokeState[]>;
|
|
15
|
+
};
|
|
16
|
+
export declare const CHAT_EMPTY_TOOL_CALL_SESSION_STATE: ChatToolCallSessionState;
|
|
9
17
|
type ChatToolCallState = {
|
|
10
|
-
|
|
11
|
-
id: string;
|
|
12
|
-
invokeStatus: string;
|
|
13
|
-
}[]>;
|
|
18
|
+
sessions: Record<string, ChatToolCallSessionState>;
|
|
14
19
|
};
|
|
15
20
|
export interface ChatToolCallActions {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
getSessionState: (sessionId: string) => ChatToolCallSessionState;
|
|
22
|
+
resetSessionState: (sessionId: string) => void;
|
|
23
|
+
migrateSessionState: (fromSessionId: string, toSessionId: string) => void;
|
|
24
|
+
updateToolCallInvokeStatus: (sessionId: string, messageId: string, toolCallId: string, invokeStatus: string) => void;
|
|
25
|
+
isAllWaiting: (sessionId: string, messageId: string) => boolean;
|
|
26
|
+
isInterrupted: (sessionId: string, messageId: string, toolCallId: string) => boolean;
|
|
27
|
+
getInvokeStatus: (sessionId: string, messageId: string, toolCallId: string) => string | undefined;
|
|
20
28
|
}
|
|
21
29
|
export declare const useChatToolCallStore: {
|
|
22
30
|
(): ChatToolCallState & ChatToolCallActions;
|
|
23
31
|
<U>(selector: (state: ChatToolCallState & ChatToolCallActions) => U): U;
|
|
24
32
|
} & import("zustand").StoreApi<ChatToolCallState & ChatToolCallActions> & {
|
|
25
33
|
use: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
updateToolCallInvokeStatus: () => (messageId: string, toolCallId: string, invokeStatus: string) => void;
|
|
31
|
-
isAllWaiting: () => (messageId: string) => boolean;
|
|
32
|
-
isInterrupted: () => (messageId: string, toolCallId: string) => boolean;
|
|
33
|
-
getInvokeStatus: () => (messageId: string, toolCallId: string) => string;
|
|
34
|
+
sessions: () => Record<string, ChatToolCallSessionState>;
|
|
35
|
+
getSessionState: () => (sessionId: string) => ChatToolCallSessionState;
|
|
36
|
+
resetSessionState: () => (sessionId: string) => void;
|
|
37
|
+
migrateSessionState: () => (fromSessionId: string, toSessionId: string) => void;
|
|
38
|
+
updateToolCallInvokeStatus: () => (sessionId: string, messageId: string, toolCallId: string, invokeStatus: string) => void;
|
|
39
|
+
isAllWaiting: () => (sessionId: string, messageId: string) => boolean;
|
|
40
|
+
isInterrupted: () => (sessionId: string, messageId: string, toolCallId: string) => boolean;
|
|
41
|
+
getInvokeStatus: () => (sessionId: string, messageId: string, toolCallId: string) => string | undefined;
|
|
34
42
|
};
|
|
35
43
|
};
|
|
36
44
|
export {};
|
package/dist/client/index.d.ts
CHANGED
|
@@ -30,8 +30,10 @@ export type { AIEmployee, ToolCall } from './ai-employees/types';
|
|
|
30
30
|
export * from './features';
|
|
31
31
|
export { AIEmployeeActionModel } from './ai-employees/flow/models/AIEmployeeActionModel';
|
|
32
32
|
export { useChatMessagesStore } from './ai-employees/chatbox/stores/chat-messages';
|
|
33
|
+
export { useChat } from './ai-employees/chatbox/hooks/useChat';
|
|
33
34
|
export { useChatBoxStore } from './ai-employees/chatbox/stores/chat-box';
|
|
34
35
|
export { useChatBoxActions } from './ai-employees/chatbox/hooks/useChatBoxActions';
|
|
36
|
+
export { useChatConversationsStore } from './ai-employees/chatbox/stores/chat-conversations';
|
|
35
37
|
export { useAIConfigRepository } from './repositories/hooks/useAIConfigRepository';
|
|
36
38
|
export { ProfileCard } from './ai-employees/ProfileCard';
|
|
37
39
|
export { avatars } from './ai-employees/avatars';
|