plugin-ai-api 1.0.14 → 1.0.20

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.
Files changed (60) hide show
  1. package/dist/client/302.25edd5d75460acbf.js +10 -0
  2. package/dist/client/757.71e30f2a1306562d.js +10 -0
  3. package/dist/client/902.4238b04ac667c30a.js +10 -0
  4. package/dist/client/97.37cda285d7da3a26.js +10 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-v2/302.9b27a263901d54d8.js +10 -0
  7. package/dist/client-v2/757.c377e2f2b054d89d.js +10 -0
  8. package/dist/client-v2/902.d40d7bda106124c8.js +10 -0
  9. package/dist/client-v2/97.fc922c37ced86831.js +10 -0
  10. package/dist/client-v2/index.js +1 -1
  11. package/dist/externalVersion.js +9 -9
  12. package/dist/locale/en-US.json +78 -2
  13. package/dist/locale/vi-VN.json +86 -0
  14. package/dist/locale/zh-CN.json +86 -10
  15. package/dist/server/billing.js +331 -0
  16. package/dist/server/collections/ai-api-config.js +12 -0
  17. package/dist/server/collections/ai-api-model-prices.js +55 -0
  18. package/dist/server/collections/ai-api-usage-records.js +9 -0
  19. package/dist/server/collections/ai-api-user-quota-buckets.js +54 -0
  20. package/dist/server/collections/ai-api-user-quota-policies.js +62 -0
  21. package/dist/server/plugin.js +23 -2
  22. package/dist/server/resource/ai-api-config.js +8 -0
  23. package/dist/server/resource/ai-api-usage-monitor.js +86 -0
  24. package/dist/server/routes/chat-completions.js +12 -2
  25. package/dist/server/routes/completions.js +12 -2
  26. package/dist/server/routes/router.js +14 -1
  27. package/dist/server/usage.js +17 -2
  28. package/dist/server/validation.js +102 -0
  29. package/package.json +1 -1
  30. package/src/client/plugin.tsx +73 -48
  31. package/src/client-v2/locale.ts +1 -0
  32. package/src/client-v2/pages/GeneralPage.tsx +170 -0
  33. package/src/client-v2/pages/ModelPricingPage.tsx +285 -0
  34. package/src/client-v2/pages/UsagePage.tsx +248 -0
  35. package/src/client-v2/pages/UserQuotasPage.tsx +258 -0
  36. package/src/client-v2/pages/api.ts +16 -0
  37. package/src/client-v2/plugin.tsx +21 -3
  38. package/src/locale/en-US.json +78 -2
  39. package/src/locale/vi-VN.json +86 -0
  40. package/src/locale/zh-CN.json +86 -10
  41. package/src/server/__tests__/billing-quota.test.ts +134 -0
  42. package/src/server/__tests__/billing.test.ts +33 -0
  43. package/src/server/__tests__/usage-monitor.test.ts +63 -0
  44. package/src/server/__tests__/usage-route.test.ts +4 -0
  45. package/src/server/billing.ts +387 -0
  46. package/src/server/collections/ai-api-config.ts +63 -51
  47. package/src/server/collections/ai-api-model-prices.ts +25 -0
  48. package/src/server/collections/ai-api-usage-records.ts +9 -0
  49. package/src/server/collections/ai-api-user-quota-buckets.ts +24 -0
  50. package/src/server/collections/ai-api-user-quota-policies.ts +32 -0
  51. package/src/server/plugin.ts +24 -2
  52. package/src/server/resource/ai-api-config.ts +82 -74
  53. package/src/server/resource/ai-api-usage-monitor.ts +74 -0
  54. package/src/server/routes/chat-completions.ts +13 -2
  55. package/src/server/routes/completions.ts +13 -2
  56. package/src/server/routes/router.ts +16 -1
  57. package/src/server/usage.ts +17 -1
  58. package/src/server/validation.ts +62 -0
  59. package/dist/client/950.83390c5f1d5a97fb.js +0 -10
  60. package/dist/client-v2/950.42b30b5cc9e32b8f.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.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).push([["302"],{581:function(e,t,r){r.r(t),r.d(t,{default:function(){return d}});var n=r(155),a=r.n(n),l=r(59),o=r(694),i=r(235),u=r(630);function c(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 s(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){s(l,n,a,o,i,"next",e)}function i(e){s(l,n,a,o,i,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}}(e,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.")}()}function f(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:u(0)}),i(o,"throw",{value:u(1)}),i(o,"return",{value:u(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var y={mode:"llm",enabledLlmServices:[],rateLimitPerMinute:60,quotaEnabled:!1,defaultReservationOutputTokens:4096};function d(){var e=(0,o.useFlowContext)(),t=(0,i.k)(),r=p(l.Form.useForm(),1)[0],c=l.Form.useWatch("mode",r),s=p((0,n.useState)(!0),2),d=s[0],b=s[1],h=p((0,n.useState)(!1),2),v=h[0],g=h[1],E=p((0,n.useState)([]),2),S=E[0],w=E[1],k=p((0,n.useState)([]),2),I=k[0],P=k[1],A=p((0,n.useState)(),2),F=A[0],C=A[1],O=(0,n.useCallback)(function(){return m(function(){var t,n,a,l,o;return f(this,function(i){switch(i.label){case 0:b(!0),C(void 0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiConfig:get",method:"get"}),e.api.request({url:"ai:listLLMServices",method:"get"}),e.api.request({url:"aiEmployees:list",method:"get",params:{paginate:!1}})])];case 2:return n=(t=p.apply(void 0,[i.sent(),3]))[0],a=t[1],l=t[2],r.setFieldsValue(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){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}({},y,(0,u.m)(n,{}))),w((0,u.m)(a,[])),P((0,u.m)(l,[])),[3,5];case 3:return o=i.sent(),C((0,u.g)(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})})()},[e.api,r]);(0,n.useEffect)(function(){O()},[O]);var L=S.map(function(e){return{label:e.title||e.name,value:e.name}}),T=I.map(function(e){return{label:e.nickname?"".concat(e.nickname," (").concat(e.username,")"):e.username,value:e.username}}),j="".concat(window.location.origin,"/api/ai-llm/v1");return a().createElement(l.Card,{title:t("Configuration"),loading:d},F?a().createElement(l.Alert,{type:"error",showIcon:!0,message:F,style:{marginBottom:16}}):null,a().createElement(l.Form,{form:r,layout:"vertical",style:{maxWidth:720},initialValues:y},a().createElement(l.Form.Item,{name:"mode",label:t("API mode"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Direct LLM"),value:"llm"},{label:t("AI Employee agent"),value:"agent"}]})),a().createElement(l.Form.Item,{name:"defaultLlmService",label:t("Default LLM service")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",options:L})),a().createElement(l.Form.Item,{name:"enabledLlmServices",label:t("Enabled LLM Services")},a().createElement(l.Select,{mode:"multiple",allowClear:!0,showSearch:!0,optionFilterProp:"label",options:L})),"agent"===c?a().createElement(l.Form.Item,{name:"defaultAiEmployee",label:t("Default AI Employee")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:t("Select an AI Employee"),options:T})):null,a().createElement(l.Form.Item,{name:"rateLimitPerMinute",label:t("Rate Limit"),rules:[{required:!0}]},a().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"quotaEnabled",label:t("Enable user quotas"),valuePropName:"checked"},a().createElement(l.Switch,null)),a().createElement(l.Form.Item,{name:"defaultReservationOutputTokens",label:t("Default reserved output tokens"),rules:[{required:!0}]},a().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),a().createElement(l.Space,null,a().createElement(l.Button,{type:"primary",loading:v,onClick:function(){return m(function(){var n,a;return f(this,function(o){switch(o.label){case 0:return[4,r.validateFields()];case 1:n=o.sent(),g(!0),o.label=2;case 2:return o.trys.push([2,4,5,6]),[4,e.api.request({url:"aiApiConfig:save",method:"post",data:n})];case 3:return o.sent(),l.message.success(t("Configuration saved")),[3,6];case 4:return a=o.sent(),l.message.error("".concat(t("Failed to save configuration"),": ").concat((0,u.g)(a))),[3,6];case 5:return g(!1),[7];case 6:return[2]}})})()}},t("Save Configuration")),a().createElement(l.Button,{onClick:O},t("Refresh")))),a().createElement(l.Card,{title:t("Usage guide"),size:"small",style:{marginTop:24}},a().createElement(l.Alert,{type:"info",showIcon:!0,message:t("OpenAI-compatible endpoint"),description:a().createElement(l.Space,{direction:"vertical",size:4},a().createElement(l.Typography.Text,null,t("Base URL")),a().createElement(l.Typography.Text,{code:!0,copyable:!0},j),a().createElement(l.Typography.Text,null,t("Use a NocoBase API key as the Bearer token."))),style:{marginBottom:16}}),a().createElement(l.Typography.Paragraph,null,t("List available models")),a().createElement(l.Typography.Paragraph,{code:!0,copyable:!0},"curl ".concat(j,'/models -H "Authorization: Bearer <your-api-key>"')),a().createElement(l.Typography.Paragraph,null,t("Send a chat completion")),a().createElement(l.Typography.Paragraph,{code:!0,copyable:!0},"curl ".concat(j,'/chat/completions \\\n -H "Authorization: Bearer <your-api-key>" \\\n -H "Content-Type: application/json" \\\n -d \'{"model":"<service>/<model>","messages":[{"role":"user","content":"Hello"}]}\''))))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).push([["757"],{364:function(e,t,r){r.r(t),r.d(t,{default:function(){return y}});var n=r(155),a=r.n(n),l=r(59),o=r(185),s=r.n(o),u=r(694),i=r(235),c=r(630);function d(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 m(e,t,r,n,a,l,o){try{var s=e[l](o),u=s.value}catch(e){r(e);return}s.done?t(u):Promise.resolve(u).then(n,a)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,s=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(s)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}(e,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.")}()}var v=function(){return[s()().subtract(29,"day").startOf("day"),s()().endOf("day")]},p={requestCount:0,inputTokens:0,outputTokens:0,totalTokens:0,costsByCurrency:[]};function y(){var e=(0,u.useFlowContext)(),t=(0,i.k)(),r=f(l.Form.useForm(),1)[0],o=f((0,n.useState)([]),2),s=o[0],d=o[1],y=f((0,n.useState)(p),2),h=y[0],S=y[1],b=f((0,n.useState)([]),2),g=b[0],k=b[1],I=f((0,n.useState)(!1),2),E=I[0],w=I[1],C=(0,n.useCallback)(function(t){var n;return(n=function(){var n,a,o,s,u,i,m,y,h,b,g;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(o,"next",{value:u(0)}),s(o,"throw",{value:u(1)}),s(o,"return",{value:u(2)}),"function"==typeof Symbol&&s(o,Symbol.iterator,{value:function(){return this}}),o;function u(s){return function(u){var i=[s,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,n=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){l.label=i[1];break}if(6===i[0]&&l.label<a[1]){l.label=a[1],a=i;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(i);break}a[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}(this,function(k){switch(k.label){case 0:s=(o=f(null!=(n=(a=null!=t?t:r.getFieldsValue()).range)?n:v(),2))[0],u=o[1],i=[{startedAt:{$gte:s.toISOString(),$lte:u.toISOString()}}],void 0!==a.userId&&i.push({userId:a.userId}),a.resolvedService&&i.push({resolvedService:a.resolvedService}),a.resolvedModel&&i.push({resolvedModel:a.resolvedModel}),a.status&&i.push({status:a.status}),m={start:s.toISOString(),end:u.toISOString(),userId:a.userId,resolvedService:a.resolvedService,resolvedModel:a.resolvedModel,status:a.status},w(!0),k.label=1;case 1:return k.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiUsageRecords:list",method:"get",params:{pageSize:100,sort:"-startedAt",filter:{$and:i}}}),e.api.request({url:"aiApiUsageMonitor:summary",method:"get",params:m})])];case 2:return h=(y=f.apply(void 0,[k.sent(),2]))[0],b=y[1],d((0,c.m)(h,[])),S((0,c.m)(b,p)),[3,5];case 3:return g=k.sent(),l.message.error((0,c.g)(g)),[3,5];case 4:return w(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,a){var l=n.apply(e,t);function o(e){m(l,r,a,o,s,"next",e)}function s(e){m(l,r,a,o,s,"throw",e)}o(void 0)})})()},[e.api,r]);(0,n.useEffect)(function(){var t=v();r.setFieldsValue({range:t}),C({range:t}),e.api.request({url:"ai:listLLMServices",method:"get"}).then(function(e){return k((0,c.m)(e,[]))}).catch(function(e){return l.message.error((0,c.g)(e))})},[e.api,r,C]);var x=h.costsByCurrency.length?h.costsByCurrency.map(function(e){return"".concat(e.totalCost," ").concat(e.currency)}).join(" + "):"0",T=[{title:t("Started at"),dataIndex:"startedAt",key:"startedAt",width:180},{title:t("User"),dataIndex:"userId",key:"userId",width:90},{title:t("Requested model"),dataIndex:"model",key:"model",width:170},{title:t("Resolved service"),dataIndex:"resolvedService",key:"resolvedService",width:170},{title:t("Resolved model"),dataIndex:"resolvedModel",key:"resolvedModel",width:170},{title:t("Input tokens"),dataIndex:"inputTokens",key:"inputTokens",width:110},{title:t("Output tokens"),dataIndex:"outputTokens",key:"outputTokens",width:110},{title:t("Total tokens"),dataIndex:"totalTokens",key:"totalTokens",width:110},{title:t("Cost"),key:"cost",width:130,render:function(e,t){var r;return null==t.estimatedCost?"-":"".concat(t.estimatedCost," ").concat(null!=(r=t.currency)?r:"")}},{title:t("Cost status"),dataIndex:"costStatus",key:"costStatus",width:130,render:function(e){return e?a().createElement(l.Tag,null,e):"-"}},{title:t("Status"),dataIndex:"status",key:"status",width:100},{title:t("Request ID"),dataIndex:"requestId",key:"requestId",width:240}];return a().createElement(l.Space,{direction:"vertical",size:16,style:{width:"100%"}},a().createElement(l.Card,{title:t("Usage filters"),size:"small"},a().createElement(l.Form,{form:r,layout:"inline",onFinish:function(e){return C(e)}},a().createElement(l.Form.Item,{name:"range",label:t("Time range"),rules:[{required:!0}]},a().createElement(l.DatePicker.RangePicker,{showTime:!0})),a().createElement(l.Form.Item,{name:"userId",label:t("User ID")},a().createElement(l.InputNumber,{min:1,style:{width:110}})),a().createElement(l.Form.Item,{name:"resolvedService",label:t("Resolved service")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",style:{width:190},options:g.map(function(e){return{label:e.title||e.name,value:e.name}})})),a().createElement(l.Form.Item,{name:"resolvedModel",label:t("Resolved model")},a().createElement(l.Input,{allowClear:!0,style:{width:180}})),a().createElement(l.Form.Item,{name:"status",label:t("Status")},a().createElement(l.Select,{allowClear:!0,style:{width:130},options:[{label:t("Succeeded"),value:"succeeded"},{label:t("Failed"),value:"failed"},{label:t("Started"),value:"started"}]})),a().createElement(l.Form.Item,null,a().createElement(l.Space,null,a().createElement(l.Button,{type:"primary",htmlType:"submit",loading:E},t("Apply filters")),a().createElement(l.Button,{onClick:function(){var e=v();r.setFieldsValue({range:e,userId:void 0,resolvedService:void 0,resolvedModel:void 0,status:void 0}),C({range:e})}},t("Reset")))))),a().createElement(l.Row,{gutter:[16,16]},a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Requests"),value:h.requestCount}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Input tokens"),value:h.inputTokens}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Output tokens"),value:h.outputTokens}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Total tokens"),value:h.totalTokens}))),a().createElement(l.Col,{xs:24},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Total cost"),value:x})))),a().createElement(l.Card,{title:t("Usage records"),extra:a().createElement(l.Button,{onClick:function(){return C()}},t("Refresh"))},a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:E,scroll:{x:1600}})))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).push([["902"],{77:function(e,t,r){r.r(t),r.d(t,{default:function(){return f}});var n=r(155),a=r.n(n),l=r(59),i=r(694),o=r(235),u=r(630);function c(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 s(e,t,r,n,a,l,i){try{var o=e[l](i),u=o.value}catch(e){r(e);return}o.done?t(u):Promise.resolve(u).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function i(e){s(l,n,a,i,o,"next",e)}function o(e){s(l,n,a,i,o,"throw",e)}i(void 0)})}}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],i=!0,o=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);i=!0);}catch(e){o=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(o)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}}(e,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.")}()}function p(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var c=[o,u];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function f(){var e=(0,i.useFlowContext)(),t=(0,o.k)(),r=d(l.Form.useForm(),1)[0],c=d((0,n.useState)([]),2),s=c[0],f=c[1],y=d((0,n.useState)([]),2),b=y[0],h=y[1],v=d((0,n.useState)(!1),2),g=v[0],E=v[1],w=d((0,n.useState)(!1),2),S=w[0],k=w[1],I=d((0,n.useState)(),2),U=I[0],q=I[1],F=d((0,n.useState)(!1),2),T=F[0],x=F[1],C=(0,n.useCallback)(function(){return m(function(){var t,r,n,a;return p(this,function(i){switch(i.label){case 0:E(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiUserQuotaPolicies:list",method:"get",params:{pageSize:200,appends:["user"],sort:"-updatedAt"}}),e.api.request({url:"users:list",method:"get",params:{pageSize:200}})])];case 2:return r=(t=d.apply(void 0,[i.sent(),2]))[0],n=t[1],f((0,u.m)(r,[])),h((0,u.m)(n,[])),[3,5];case 3:return a=i.sent(),l.message.error((0,u.g)(a)),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})()},[e.api]);(0,n.useEffect)(function(){C()},[C]);var A=function(e){q(e),r.setFieldsValue(e),x(!0)},P=function(e){var t;return(null==e?void 0:e.nickname)||(null==e?void 0:e.username)||(null==e?void 0:e.email)||String(null!=(t=null==e?void 0:e.id)?t:"")},j=[{title:t("User"),key:"user",width:180,render:function(e,t){return P(t.user)||String(t.userId)}},{title:t("Period"),dataIndex:"periodType",key:"periodType",width:100},{title:t("Request limit"),dataIndex:"requestLimit",key:"requestLimit",width:130,render:function(e){return null!=e?e:t("Unlimited")}},{title:t("Token limit"),dataIndex:"totalTokenLimit",key:"totalTokenLimit",width:130,render:function(e){return null!=e?e:t("Unlimited")}},{title:t("Cost limit"),dataIndex:"costLimit",key:"costLimit",width:120,render:function(e,r){return null==e?t("Unlimited"):"".concat(e," ").concat(r.currency)}},{title:t("Timezone"),dataIndex:"timezone",key:"timezone",width:140},{title:t("Status"),dataIndex:"enabled",key:"enabled",width:100,render:function(e){return a().createElement(l.Tag,{color:e?"green":"default"},e?t("Enabled"):t("Disabled"))}},{title:t("Actions"),key:"actions",width:150,fixed:"right",render:function(r,n){return a().createElement(l.Space,{size:0},a().createElement(l.Button,{type:"link",onClick:function(){return A(n)}},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this quota?"),onConfirm:function(){return m(function(){var r;return p(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,e.api.request({url:"aiApiUserQuotaPolicies:destroy/".concat(n.id),method:"post"})];case 1:return a.sent(),l.message.success(t("Deleted successfully")),[4,C()];case 2:return a.sent(),[3,4];case 3:return r=a.sent(),l.message.error((0,u.g)(r)),[3,4];case 4:return[2]}})})()}},a().createElement(l.Button,{type:"link",danger:!0},t("Delete"))))}}];return a().createElement(l.Card,{title:t("User quotas"),extra:a().createElement(l.Button,{type:"primary",onClick:function(){q(void 0),r.setFieldsValue({enabled:!0,periodType:"monthly",timezone:"UTC",currency:"USD",rejectUnpricedModel:!0,missingUsageBehavior:"use_reserved"}),x(!0)}},t("Add quota"))},a().createElement(l.Table,{rowKey:"id",columns:j,dataSource:s,loading:g,scroll:{x:1100}}),a().createElement(l.Modal,{title:U?t("Edit quota"):t("Add quota"),open:T,onCancel:function(){return x(!1)},onOk:function(){return m(function(){var n,a;return p(this,function(i){switch(i.label){case 0:return[4,r.validateFields()];case 1:n=i.sent(),k(!0),i.label=2;case 2:return i.trys.push([2,5,6,7]),[4,e.api.request({url:U?"aiApiUserQuotaPolicies:update/".concat(U.id):"aiApiUserQuotaPolicies:create",method:"post",data:n})];case 3:return i.sent(),l.message.success(t("Saved successfully")),x(!1),[4,C()];case 4:return i.sent(),[3,7];case 5:return a=i.sent(),l.message.error((0,u.g)(a)),[3,7];case 6:return k(!1),[7];case 7:return[2]}})})()},confirmLoading:S,destroyOnClose:!0},a().createElement(l.Form,{form:r,layout:"vertical",preserve:!1},a().createElement(l.Form.Item,{name:"userId",label:t("User"),rules:[{required:!0}]},a().createElement(l.Select,{disabled:!!U,showSearch:!0,optionFilterProp:"label",options:b.map(function(e){return{label:P(e),value:e.id}})})),a().createElement(l.Form.Item,{name:"periodType",label:t("Period"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Daily"),value:"daily"},{label:t("Monthly"),value:"monthly"}]})),a().createElement(l.Form.Item,{name:"timezone",label:t("Timezone"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"UTC"})),a().createElement(l.Form.Item,{name:"requestLimit",label:t("Request limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"totalTokenLimit",label:t("Token limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"costLimit",label:t("Cost limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"currency",label:t("Currency"),rules:[{required:!0}]},a().createElement(l.Input,null)),a().createElement(l.Form.Item,{name:"rejectUnpricedModel",label:t("Reject unpriced models"),valuePropName:"checked"},a().createElement(l.Switch,null)),a().createElement(l.Form.Item,{name:"missingUsageBehavior",label:t("Missing usage behavior"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Use reserved estimate"),value:"use_reserved"},{label:t("Allow without token charge"),value:"allow"}]})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked"},a().createElement(l.Switch,null)))))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).push([["97"],{760:function(e,t,r){r.r(t),r.d(t,{default:function(){return g}});var n=r(155),o=r.n(n),i=r(59),l=r(185),a=r.n(l),u=r(694),c=r(235),s=r(630);function m(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 f(e,t,r,n,o,i,l){try{var a=e[i](l),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function l(e){f(i,n,o,l,a,"next",e)}function a(e){f(i,n,o,l,a,"throw",e)}l(void 0)})}}function p(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){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw n}}return i}}(e,t)||v(e,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.")}()}function v(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}function h(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function g(){var e=(0,u.useFlowContext)(),t=(0,c.k)(),r=b(i.Form.useForm(),1)[0],l=i.Form.useWatch("llmService",r),f=b((0,n.useState)([]),2),g=f[0],S=f[1],w=b((0,n.useState)([]),2),E=w[0],P=w[1],I=b((0,n.useState)([]),2),k=I[0],O=I[1],F=b((0,n.useState)(!1),2),M=F[0],x=F[1],j=b((0,n.useState)(!1),2),T=j[0],C=j[1],q=b((0,n.useState)(!1),2),A=q[0],D=q[1],L=b((0,n.useState)(),2),N=L[0],U=L[1],_=b((0,n.useState)(!1),2),B=_[0],R=_[1],V=(0,n.useCallback)(function(){return d(function(){var t,r,n,o;return h(this,function(l){switch(l.label){case 0:C(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiModelPrices:list",method:"get",params:{pageSize:200,sort:"-effectiveFrom"}}),e.api.request({url:"ai:listLLMServices",method:"get"})])];case 2:return r=(t=b.apply(void 0,[l.sent(),2]))[0],n=t[1],S((0,s.m)(r,[])),P((0,s.m)(n,[])),[3,5];case 3:return o=l.sent(),i.message.error((0,s.g)(o)),[3,5];case 4:return C(!1),[7];case 5:return[2]}})})()},[e.api]);(0,n.useEffect)(function(){V()},[V]);var z=function(e){U(e),r.setFieldsValue(y(p({},e),{effectiveFrom:a()(e.effectiveFrom),effectiveTo:e.effectiveTo?a()(e.effectiveTo):void 0})),R(!0),G(e.llmService,e.model)},G=function(r,n){return d(function(){var o,l,a;return h(this,function(u){switch(u.label){case 0:x(!0),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,e.api.request({url:"ai:listModels",method:"get",params:{llmService:r}})];case 2:return o=u.sent(),l=(0,s.m)(o,[]),O(n&&!l.some(function(e){return e.id===n})?[{id:n}].concat(function(e){if(Array.isArray(e))return m(e)}(l)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||v(l)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):l),[3,5];case 3:return a=u.sent(),O(n?[{id:n}]:[]),i.message.error("".concat(t("Failed to load models"),": ").concat((0,s.g)(a))),[3,5];case 4:return x(!1),[7];case 5:return[2]}})})()},J=[{title:t("LLM service"),dataIndex:"llmService",key:"llmService",width:180},{title:t("Model"),dataIndex:"model",key:"model",width:180},{title:t("Input price / 1M"),dataIndex:"inputPricePerMillionTokens",key:"inputPrice",width:150},{title:t("Output price / 1M"),dataIndex:"outputPricePerMillionTokens",key:"outputPrice",width:150},{title:t("Fixed request cost"),dataIndex:"fixedCostPerRequest",key:"fixedCost",width:150},{title:t("Currency"),dataIndex:"currency",key:"currency",width:90},{title:t("Status"),dataIndex:"enabled",key:"enabled",width:100,render:function(e){return o().createElement(i.Tag,{color:e?"green":"default"},e?t("Enabled"):t("Disabled"))}},{title:t("Actions"),key:"actions",fixed:"right",width:150,render:function(r,n){return o().createElement(i.Space,null,o().createElement(i.Button,{type:"link",onClick:function(){return z(n)}},t("Edit")),o().createElement(i.Popconfirm,{title:t("Delete this price?"),onConfirm:function(){var r;return r=n.id,d(function(){var n;return h(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,e.api.request({url:"aiApiModelPrices:destroy/".concat(r),method:"post"})];case 1:return o.sent(),i.message.success(t("Deleted successfully")),[4,V()];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),i.message.error((0,s.g)(n)),[3,4];case 4:return[2]}})})()}},o().createElement(i.Button,{type:"link",danger:!0},t("Delete"))))}}];return o().createElement(i.Card,{title:t("Model pricing"),extra:o().createElement(i.Button,{type:"primary",onClick:function(){U(void 0),O([]),r.setFieldsValue({currency:"USD",inputPricePerMillionTokens:"0",outputPricePerMillionTokens:"0",fixedCostPerRequest:"0",effectiveFrom:a()(),enabled:!0}),R(!0)}},t("Add price"))},o().createElement(i.Table,{rowKey:"id",columns:J,dataSource:g,loading:T,scroll:{x:1200}}),o().createElement(i.Modal,{title:N?t("Edit price"):t("Add price"),open:B,onCancel:function(){return R(!1)},onOk:function(){return d(function(){var n,o,l,a,u,c,m;return h(this,function(f){switch(f.label){case 0:return[4,r.validateFields()];case 1:a=f.sent(),u=E.find(function(e){return e.name===a.llmService}),c=y(p({},a),{provider:null!=(n=null==u?void 0:u.provider)?n:a.provider,effectiveFrom:a.effectiveFrom.toISOString(),effectiveTo:null!=(o=null==(l=a.effectiveTo)?void 0:l.toISOString())?o:null}),D(!0),f.label=2;case 2:return f.trys.push([2,5,6,7]),[4,e.api.request({url:N?"aiApiModelPrices:update/".concat(N.id):"aiApiModelPrices:create",method:"post",data:c})];case 3:return f.sent(),i.message.success(t("Saved successfully")),R(!1),[4,V()];case 4:return f.sent(),[3,7];case 5:return m=f.sent(),i.message.error((0,s.g)(m)),[3,7];case 6:return D(!1),[7];case 7:return[2]}})})()},confirmLoading:A,destroyOnClose:!0},o().createElement(i.Form,{form:r,layout:"vertical",preserve:!1},o().createElement(i.Form.Item,{name:"llmService",label:t("LLM service"),rules:[{required:!0}]},o().createElement(i.Select,{showSearch:!0,optionFilterProp:"label",onChange:function(e){r.setFieldValue("model",void 0),O([]),G(e)},options:E.map(function(e){return{label:e.title||e.name,value:e.name}})})),o().createElement(i.Form.Item,{name:"provider",hidden:!0},o().createElement(i.Input,null)),o().createElement(i.Form.Item,{name:"model",label:t("Model"),rules:[{required:!0}]},o().createElement(i.Select,{showSearch:!0,optionFilterProp:"label",loading:M,disabled:!l,placeholder:t("Select a model"),options:k.map(function(e){return{label:e.id,value:e.id}})})),o().createElement(i.Form.Item,{name:"currency",label:t("Currency"),rules:[{required:!0}]},o().createElement(i.Input,null)),o().createElement(i.Form.Item,{name:"inputPricePerMillionTokens",label:t("Input price / 1M"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"outputPricePerMillionTokens",label:t("Output price / 1M"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"fixedCostPerRequest",label:t("Fixed request cost"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"effectiveFrom",label:t("Effective from"),rules:[{required:!0}]},o().createElement(i.DatePicker,{showTime:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"effectiveTo",label:t("Effective to")},o().createElement(i.DatePicker,{showTime:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked"},o().createElement(i.Switch,null)),o().createElement(i.Form.Item,{name:"notes",label:t("Notes")},o().createElement(i.Input.TextArea,{rows:3})))))}},235:function(e,t,r){r.d(t,{k:function(){return i}});var n=r(694),o=JSON.parse('{"UU":"plugin-ai-api"}');function i(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function o(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return o},m:function(){return n}})}}]);
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-acl/client")):"function"==typeof define&&define.amd?define("plugin-ai-api",["@nocobase/client-v2","react","antd","@nocobase/client","@nocobase/plugin-acl/client"],t):"object"==typeof exports?exports["plugin-ai-api"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-acl/client")):e["plugin-ai-api"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/plugin-acl/client"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,a,u,c={342:function(e){e.exports=r},485:function(t){t.exports=e},79:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e](n,n.exports,p),n.exports}p.m=c,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({778:"5c452944cb747975",950:"83390c5f1d5a97fb"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},p.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-ai-api:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","plugin-ai-api:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=f[e];if(delete f[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(s=p.g.location+"");var f,s,d=p.g.document;if(!s&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(s=d.currentScript.src),!s)){var b=d.getElementsByTagName("script");if(b.length)for(var h=b.length-1;h>-1&&(!s||!/^http(s?):/.test(s));)s=b[h--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");p.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},p.f.j=function(e,t){var n=p.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),a=Error();p.l(o,function(t){if(p.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,n[1](a)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],a=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==i[e]})){for(n in a)p.o(a,n)&&(p.m[n]=a[n]);u&&u(p)}for(e&&e(t);c<o.length;c++)r=o[c],p.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(u=self.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).forEach(a.bind(null,0)),u.push=a.bind(null,u.push.bind(u));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-ai-api/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-ai-api/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-ai-api/dist/client/"}p.p=e}(),!function(){p.r(v),p.d(v,{default:function(){return b}});var e=p(342),t=p(79),n=p.n(t),r=p(155),o=p.n(r);function i(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function a(e,t,n){return(a=f()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var s=o().lazy(function(){return p.e("950").then(p.bind(p,693))}),d=(0,e.lazy)(function(){return p.e("778").then(p.bind(p,905))},"AiApiRolePermissions").AiApiRolePermissions,b=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=u(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,f()?Reflect.construct(e,t||[],u(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&c(r,e),t=[{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={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),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return this.app.pluginSettingsManager.add("ai-api",{icon:"ApiOutlined",title:this.t("AI API Gateway"),aclSnippet:"pm.ai-api.configuration"}),this.app.pluginSettingsManager.add("ai-api.config",{title:this.t("Configuration"),Component:s}),(null==(e=this.app.pm.get(n()))?void 0:e.settingsUI)&&e.settingsUI.addPermissionsTab(function(e){e.t;var t=e.TabLayout,n=e.activeRole;return{key:"aiApi",label:"AI API",sort:25,children:o().createElement(t,null,o().createElement(d,{role:n}))}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,t),r}(l(e.Plugin))}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-acl/client"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-ai-api",["@nocobase/client-v2","dayjs","react","antd","@nocobase/client","@nocobase/plugin-acl/client","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-ai-api"]=t(require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-acl/client"),require("@nocobase/flow-engine")):e["plugin-ai-api"]=t(e["@nocobase/client-v2"],e.dayjs,e.react,e.antd,e["@nocobase/client"],e["@nocobase/plugin-acl/client"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,i,o,a){return function(){"use strict";var u,c,l,p={342:function(e){e.exports=i},485:function(t){t.exports=e},694:function(e){e.exports=a},79:function(e){e.exports=o},59:function(e){e.exports=r},185:function(e){e.exports=t},155:function(e){e.exports=n}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return p[e](n,n.exports,f),n.exports}f.m=p,f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.f={},f.e=function(e){return Promise.all(Object.keys(f.f).reduce(function(t,n){return f.f[n](e,t),t},[]))},f.u=function(e){return""+e+"."+({302:"25edd5d75460acbf",757:"71e30f2a1306562d",778:"5c452944cb747975",902:"4238b04ac667c30a",97:"37cda285d7da3a26"})[e]+".js"},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d={},f.l=function(e,t,n,r){if(d[e])return void d[e].push(t);if(void 0!==n)for(var i,o,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-ai-api:"+n){i=c;break}}i||(o=!0,(i=document.createElement("script")).timeout=120,f.nc&&i.setAttribute("nonce",f.nc),i.setAttribute("data-rspack","plugin-ai-api:"+n),i.src=e),d[e]=[t];var l=function(t,n){i.onerror=i.onload=null,clearTimeout(p);var r=d[e];if(delete d[e],i.parentNode&&i.parentNode.removeChild(i),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=l.bind(null,i.onerror),i.onload=l.bind(null,i.onload),o&&document.head.appendChild(i)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(b=f.g.location+"");var d,b,g=f.g.document;if(!b&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(b=g.currentScript.src),!b)){var h=g.getElementsByTagName("script");if(h.length)for(var y=h.length-1;y>-1&&(!b||!/^http(s?):/.test(b));)b=h[y--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");f.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},f.f.j=function(e,t){var n=f.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var i=f.p+f.u(e),o=Error();f.l(i,function(t){if(f.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;o.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",o.name="ChunkLoadError",o.type=r,o.request=i,n[1](o)}},"chunk-"+e,e)}},c=function(e,t){var n,r,i=t[0],o=t[1],a=t[2],c=0;if(i.some(function(e){return 0!==u[e]})){for(n in o)f.o(o,n)&&(f.m[n]=o[n]);a&&a(f)}for(e&&e(t);c<i.length;c++)r=i[c],f.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(l=self.webpackChunkplugin_ai_api=self.webpackChunkplugin_ai_api||[]).forEach(c.bind(null,0)),l.push=c.bind(null,l.push.bind(l));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-ai-api/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-ai-api/dist/client/")}if(!e){var i=window.__nocobase_modern_client_prefix__||"v",o="/"+(i=String(i).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(o);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+i+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-ai-api/dist/client/"}f.p=e}(),!function(){f.r(v),f.d(v,{default:function(){return y}});var e=f(342),t=f(79),n=f.n(t),r=f(155),i=f.n(r);function o(e,t,n,r,i,o,a){try{var u=e[o](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,i)}function a(e,t,n){return(a=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&c(i,n.prototype),i}).apply(null,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}var s=i().lazy(function(){return f.e("302").then(f.bind(f,581))}),d=i().lazy(function(){return f.e("97").then(f.bind(f,760))}),b=i().lazy(function(){return f.e("902").then(f.bind(f,77))}),g=i().lazy(function(){return f.e("757").then(f.bind(f,364))}),h=(0,e.lazy)(function(){return f.e("778").then(f.bind(f,905))},"AiApiRolePermissions").AiApiRolePermissions,y=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=u(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(e,t||[],u(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&c(r,e),t=[{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(6===l[0]&&o.label<i[1]){o.label=i[1],i=l;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(l);break}i[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return this.app.pluginSettingsManager.add("ai-api",{icon:"ApiOutlined",title:this.t("AI API Gateway"),aclSnippet:"pm.ai-api.configuration"}),this.app.pluginSettingsManager.add("ai-api.config",{title:this.t("Configuration"),Component:s,aclSnippet:"pm.ai-api.configuration",sort:1}),this.app.pluginSettingsManager.add("ai-api.model-pricing",{title:this.t("Model pricing"),Component:d,aclSnippet:"pm.ai-api.configuration",sort:2}),this.app.pluginSettingsManager.add("ai-api.user-quotas",{title:this.t("User quotas"),Component:b,aclSnippet:"pm.ai-api.configuration",sort:3}),this.app.pluginSettingsManager.add("ai-api.usage",{title:this.t("Usage"),Component:g,aclSnippet:"pm.ai-api.configuration",sort:4}),(null==(e=this.app.pm.get(n()))?void 0:e.settingsUI)&&e.settingsUI.addPermissionsTab(function(e){e.t;var t=e.TabLayout,n=e.activeRole;return{key:"aiApi",label:"AI API",sort:25,children:i().createElement(t,null,i().createElement(h,{role:n}))}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function u(e){o(a,r,i,u,c,"next",e)}function c(e){o(a,r,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,t),r}(l(e.Plugin))}(),v}()});
@@ -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.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).push([["302"],{581:function(e,t,r){r.r(t),r.d(t,{default:function(){return d}});var n=r(155),a=r.n(n),l=r(59),o=r(694),i=r(235),u=r(630);function c(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 s(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){s(l,n,a,o,i,"next",e)}function i(e){s(l,n,a,o,i,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}}(e,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.")}()}function f(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:u(0)}),i(o,"throw",{value:u(1)}),i(o,"return",{value:u(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var y={mode:"llm",enabledLlmServices:[],rateLimitPerMinute:60,quotaEnabled:!1,defaultReservationOutputTokens:4096};function d(){var e=(0,o.useFlowContext)(),t=(0,i.k)(),r=p(l.Form.useForm(),1)[0],c=l.Form.useWatch("mode",r),s=p((0,n.useState)(!0),2),d=s[0],b=s[1],h=p((0,n.useState)(!1),2),v=h[0],g=h[1],E=p((0,n.useState)([]),2),S=E[0],w=E[1],k=p((0,n.useState)([]),2),I=k[0],P=k[1],A=p((0,n.useState)(),2),F=A[0],C=A[1],O=(0,n.useCallback)(function(){return m(function(){var t,n,a,l,o;return f(this,function(i){switch(i.label){case 0:b(!0),C(void 0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiConfig:get",method:"get"}),e.api.request({url:"ai:listLLMServices",method:"get"}),e.api.request({url:"aiEmployees:list",method:"get",params:{paginate:!1}})])];case 2:return n=(t=p.apply(void 0,[i.sent(),3]))[0],a=t[1],l=t[2],r.setFieldsValue(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){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}({},y,(0,u.m)(n,{}))),w((0,u.m)(a,[])),P((0,u.m)(l,[])),[3,5];case 3:return o=i.sent(),C((0,u.g)(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})})()},[e.api,r]);(0,n.useEffect)(function(){O()},[O]);var L=S.map(function(e){return{label:e.title||e.name,value:e.name}}),T=I.map(function(e){return{label:e.nickname?"".concat(e.nickname," (").concat(e.username,")"):e.username,value:e.username}}),j="".concat(window.location.origin,"/api/ai-llm/v1");return a().createElement(l.Card,{title:t("Configuration"),loading:d},F?a().createElement(l.Alert,{type:"error",showIcon:!0,message:F,style:{marginBottom:16}}):null,a().createElement(l.Form,{form:r,layout:"vertical",style:{maxWidth:720},initialValues:y},a().createElement(l.Form.Item,{name:"mode",label:t("API mode"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Direct LLM"),value:"llm"},{label:t("AI Employee agent"),value:"agent"}]})),a().createElement(l.Form.Item,{name:"defaultLlmService",label:t("Default LLM service")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",options:L})),a().createElement(l.Form.Item,{name:"enabledLlmServices",label:t("Enabled LLM Services")},a().createElement(l.Select,{mode:"multiple",allowClear:!0,showSearch:!0,optionFilterProp:"label",options:L})),"agent"===c?a().createElement(l.Form.Item,{name:"defaultAiEmployee",label:t("Default AI Employee")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:t("Select an AI Employee"),options:T})):null,a().createElement(l.Form.Item,{name:"rateLimitPerMinute",label:t("Rate Limit"),rules:[{required:!0}]},a().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"quotaEnabled",label:t("Enable user quotas"),valuePropName:"checked"},a().createElement(l.Switch,null)),a().createElement(l.Form.Item,{name:"defaultReservationOutputTokens",label:t("Default reserved output tokens"),rules:[{required:!0}]},a().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),a().createElement(l.Space,null,a().createElement(l.Button,{type:"primary",loading:v,onClick:function(){return m(function(){var n,a;return f(this,function(o){switch(o.label){case 0:return[4,r.validateFields()];case 1:n=o.sent(),g(!0),o.label=2;case 2:return o.trys.push([2,4,5,6]),[4,e.api.request({url:"aiApiConfig:save",method:"post",data:n})];case 3:return o.sent(),l.message.success(t("Configuration saved")),[3,6];case 4:return a=o.sent(),l.message.error("".concat(t("Failed to save configuration"),": ").concat((0,u.g)(a))),[3,6];case 5:return g(!1),[7];case 6:return[2]}})})()}},t("Save Configuration")),a().createElement(l.Button,{onClick:O},t("Refresh")))),a().createElement(l.Card,{title:t("Usage guide"),size:"small",style:{marginTop:24}},a().createElement(l.Alert,{type:"info",showIcon:!0,message:t("OpenAI-compatible endpoint"),description:a().createElement(l.Space,{direction:"vertical",size:4},a().createElement(l.Typography.Text,null,t("Base URL")),a().createElement(l.Typography.Text,{code:!0,copyable:!0},j),a().createElement(l.Typography.Text,null,t("Use a NocoBase API key as the Bearer token."))),style:{marginBottom:16}}),a().createElement(l.Typography.Paragraph,null,t("List available models")),a().createElement(l.Typography.Paragraph,{code:!0,copyable:!0},"curl ".concat(j,'/models -H "Authorization: Bearer <your-api-key>"')),a().createElement(l.Typography.Paragraph,null,t("Send a chat completion")),a().createElement(l.Typography.Paragraph,{code:!0,copyable:!0},"curl ".concat(j,'/chat/completions \\\n -H "Authorization: Bearer <your-api-key>" \\\n -H "Content-Type: application/json" \\\n -d \'{"model":"<service>/<model>","messages":[{"role":"user","content":"Hello"}]}\''))))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).push([["757"],{364:function(e,t,r){r.r(t),r.d(t,{default:function(){return y}});var n=r(155),a=r.n(n),l=r(59),o=r(185),s=r.n(o),u=r(694),i=r(235),c=r(630);function d(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 m(e,t,r,n,a,l,o){try{var s=e[l](o),u=s.value}catch(e){r(e);return}s.done?t(u):Promise.resolve(u).then(n,a)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,s=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(s)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}(e,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.")}()}var v=function(){return[s()().subtract(29,"day").startOf("day"),s()().endOf("day")]},p={requestCount:0,inputTokens:0,outputTokens:0,totalTokens:0,costsByCurrency:[]};function y(){var e=(0,u.useFlowContext)(),t=(0,i.k)(),r=f(l.Form.useForm(),1)[0],o=f((0,n.useState)([]),2),s=o[0],d=o[1],y=f((0,n.useState)(p),2),h=y[0],S=y[1],b=f((0,n.useState)([]),2),g=b[0],k=b[1],I=f((0,n.useState)(!1),2),E=I[0],w=I[1],C=(0,n.useCallback)(function(t){var n;return(n=function(){var n,a,o,s,u,i,m,y,h,b,g;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(o,"next",{value:u(0)}),s(o,"throw",{value:u(1)}),s(o,"return",{value:u(2)}),"function"==typeof Symbol&&s(o,Symbol.iterator,{value:function(){return this}}),o;function u(s){return function(u){var i=[s,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,n=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){l.label=i[1];break}if(6===i[0]&&l.label<a[1]){l.label=a[1],a=i;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(i);break}a[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}(this,function(k){switch(k.label){case 0:s=(o=f(null!=(n=(a=null!=t?t:r.getFieldsValue()).range)?n:v(),2))[0],u=o[1],i=[{startedAt:{$gte:s.toISOString(),$lte:u.toISOString()}}],void 0!==a.userId&&i.push({userId:a.userId}),a.resolvedService&&i.push({resolvedService:a.resolvedService}),a.resolvedModel&&i.push({resolvedModel:a.resolvedModel}),a.status&&i.push({status:a.status}),m={start:s.toISOString(),end:u.toISOString(),userId:a.userId,resolvedService:a.resolvedService,resolvedModel:a.resolvedModel,status:a.status},w(!0),k.label=1;case 1:return k.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiUsageRecords:list",method:"get",params:{pageSize:100,sort:"-startedAt",filter:{$and:i}}}),e.api.request({url:"aiApiUsageMonitor:summary",method:"get",params:m})])];case 2:return h=(y=f.apply(void 0,[k.sent(),2]))[0],b=y[1],d((0,c.m)(h,[])),S((0,c.m)(b,p)),[3,5];case 3:return g=k.sent(),l.message.error((0,c.g)(g)),[3,5];case 4:return w(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,a){var l=n.apply(e,t);function o(e){m(l,r,a,o,s,"next",e)}function s(e){m(l,r,a,o,s,"throw",e)}o(void 0)})})()},[e.api,r]);(0,n.useEffect)(function(){var t=v();r.setFieldsValue({range:t}),C({range:t}),e.api.request({url:"ai:listLLMServices",method:"get"}).then(function(e){return k((0,c.m)(e,[]))}).catch(function(e){return l.message.error((0,c.g)(e))})},[e.api,r,C]);var x=h.costsByCurrency.length?h.costsByCurrency.map(function(e){return"".concat(e.totalCost," ").concat(e.currency)}).join(" + "):"0",T=[{title:t("Started at"),dataIndex:"startedAt",key:"startedAt",width:180},{title:t("User"),dataIndex:"userId",key:"userId",width:90},{title:t("Requested model"),dataIndex:"model",key:"model",width:170},{title:t("Resolved service"),dataIndex:"resolvedService",key:"resolvedService",width:170},{title:t("Resolved model"),dataIndex:"resolvedModel",key:"resolvedModel",width:170},{title:t("Input tokens"),dataIndex:"inputTokens",key:"inputTokens",width:110},{title:t("Output tokens"),dataIndex:"outputTokens",key:"outputTokens",width:110},{title:t("Total tokens"),dataIndex:"totalTokens",key:"totalTokens",width:110},{title:t("Cost"),key:"cost",width:130,render:function(e,t){var r;return null==t.estimatedCost?"-":"".concat(t.estimatedCost," ").concat(null!=(r=t.currency)?r:"")}},{title:t("Cost status"),dataIndex:"costStatus",key:"costStatus",width:130,render:function(e){return e?a().createElement(l.Tag,null,e):"-"}},{title:t("Status"),dataIndex:"status",key:"status",width:100},{title:t("Request ID"),dataIndex:"requestId",key:"requestId",width:240}];return a().createElement(l.Space,{direction:"vertical",size:16,style:{width:"100%"}},a().createElement(l.Card,{title:t("Usage filters"),size:"small"},a().createElement(l.Form,{form:r,layout:"inline",onFinish:function(e){return C(e)}},a().createElement(l.Form.Item,{name:"range",label:t("Time range"),rules:[{required:!0}]},a().createElement(l.DatePicker.RangePicker,{showTime:!0})),a().createElement(l.Form.Item,{name:"userId",label:t("User ID")},a().createElement(l.InputNumber,{min:1,style:{width:110}})),a().createElement(l.Form.Item,{name:"resolvedService",label:t("Resolved service")},a().createElement(l.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",style:{width:190},options:g.map(function(e){return{label:e.title||e.name,value:e.name}})})),a().createElement(l.Form.Item,{name:"resolvedModel",label:t("Resolved model")},a().createElement(l.Input,{allowClear:!0,style:{width:180}})),a().createElement(l.Form.Item,{name:"status",label:t("Status")},a().createElement(l.Select,{allowClear:!0,style:{width:130},options:[{label:t("Succeeded"),value:"succeeded"},{label:t("Failed"),value:"failed"},{label:t("Started"),value:"started"}]})),a().createElement(l.Form.Item,null,a().createElement(l.Space,null,a().createElement(l.Button,{type:"primary",htmlType:"submit",loading:E},t("Apply filters")),a().createElement(l.Button,{onClick:function(){var e=v();r.setFieldsValue({range:e,userId:void 0,resolvedService:void 0,resolvedModel:void 0,status:void 0}),C({range:e})}},t("Reset")))))),a().createElement(l.Row,{gutter:[16,16]},a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Requests"),value:h.requestCount}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Input tokens"),value:h.inputTokens}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Output tokens"),value:h.outputTokens}))),a().createElement(l.Col,{xs:24,sm:12,lg:6},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Total tokens"),value:h.totalTokens}))),a().createElement(l.Col,{xs:24},a().createElement(l.Card,{size:"small"},a().createElement(l.Statistic,{title:t("Total cost"),value:x})))),a().createElement(l.Card,{title:t("Usage records"),extra:a().createElement(l.Button,{onClick:function(){return C()}},t("Refresh"))},a().createElement(l.Table,{rowKey:"id",columns:T,dataSource:s,loading:E,scroll:{x:1600}})))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).push([["902"],{77:function(e,t,r){r.r(t),r.d(t,{default:function(){return f}});var n=r(155),a=r.n(n),l=r(59),i=r(694),o=r(235),u=r(630);function c(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 s(e,t,r,n,a,l,i){try{var o=e[l](i),u=o.value}catch(e){r(e);return}o.done?t(u):Promise.resolve(u).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function i(e){s(l,n,a,i,o,"next",e)}function o(e){s(l,n,a,i,o,"throw",e)}i(void 0)})}}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],i=!0,o=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);i=!0);}catch(e){o=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(o)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}}(e,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.")}()}function p(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var c=[o,u];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function f(){var e=(0,i.useFlowContext)(),t=(0,o.k)(),r=d(l.Form.useForm(),1)[0],c=d((0,n.useState)([]),2),s=c[0],f=c[1],y=d((0,n.useState)([]),2),b=y[0],h=y[1],v=d((0,n.useState)(!1),2),g=v[0],E=v[1],w=d((0,n.useState)(!1),2),S=w[0],k=w[1],I=d((0,n.useState)(),2),U=I[0],q=I[1],F=d((0,n.useState)(!1),2),T=F[0],x=F[1],C=(0,n.useCallback)(function(){return m(function(){var t,r,n,a;return p(this,function(i){switch(i.label){case 0:E(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiUserQuotaPolicies:list",method:"get",params:{pageSize:200,appends:["user"],sort:"-updatedAt"}}),e.api.request({url:"users:list",method:"get",params:{pageSize:200}})])];case 2:return r=(t=d.apply(void 0,[i.sent(),2]))[0],n=t[1],f((0,u.m)(r,[])),h((0,u.m)(n,[])),[3,5];case 3:return a=i.sent(),l.message.error((0,u.g)(a)),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})()},[e.api]);(0,n.useEffect)(function(){C()},[C]);var A=function(e){q(e),r.setFieldsValue(e),x(!0)},P=function(e){var t;return(null==e?void 0:e.nickname)||(null==e?void 0:e.username)||(null==e?void 0:e.email)||String(null!=(t=null==e?void 0:e.id)?t:"")},j=[{title:t("User"),key:"user",width:180,render:function(e,t){return P(t.user)||String(t.userId)}},{title:t("Period"),dataIndex:"periodType",key:"periodType",width:100},{title:t("Request limit"),dataIndex:"requestLimit",key:"requestLimit",width:130,render:function(e){return null!=e?e:t("Unlimited")}},{title:t("Token limit"),dataIndex:"totalTokenLimit",key:"totalTokenLimit",width:130,render:function(e){return null!=e?e:t("Unlimited")}},{title:t("Cost limit"),dataIndex:"costLimit",key:"costLimit",width:120,render:function(e,r){return null==e?t("Unlimited"):"".concat(e," ").concat(r.currency)}},{title:t("Timezone"),dataIndex:"timezone",key:"timezone",width:140},{title:t("Status"),dataIndex:"enabled",key:"enabled",width:100,render:function(e){return a().createElement(l.Tag,{color:e?"green":"default"},e?t("Enabled"):t("Disabled"))}},{title:t("Actions"),key:"actions",width:150,fixed:"right",render:function(r,n){return a().createElement(l.Space,{size:0},a().createElement(l.Button,{type:"link",onClick:function(){return A(n)}},t("Edit")),a().createElement(l.Popconfirm,{title:t("Delete this quota?"),onConfirm:function(){return m(function(){var r;return p(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,e.api.request({url:"aiApiUserQuotaPolicies:destroy/".concat(n.id),method:"post"})];case 1:return a.sent(),l.message.success(t("Deleted successfully")),[4,C()];case 2:return a.sent(),[3,4];case 3:return r=a.sent(),l.message.error((0,u.g)(r)),[3,4];case 4:return[2]}})})()}},a().createElement(l.Button,{type:"link",danger:!0},t("Delete"))))}}];return a().createElement(l.Card,{title:t("User quotas"),extra:a().createElement(l.Button,{type:"primary",onClick:function(){q(void 0),r.setFieldsValue({enabled:!0,periodType:"monthly",timezone:"UTC",currency:"USD",rejectUnpricedModel:!0,missingUsageBehavior:"use_reserved"}),x(!0)}},t("Add quota"))},a().createElement(l.Table,{rowKey:"id",columns:j,dataSource:s,loading:g,scroll:{x:1100}}),a().createElement(l.Modal,{title:U?t("Edit quota"):t("Add quota"),open:T,onCancel:function(){return x(!1)},onOk:function(){return m(function(){var n,a;return p(this,function(i){switch(i.label){case 0:return[4,r.validateFields()];case 1:n=i.sent(),k(!0),i.label=2;case 2:return i.trys.push([2,5,6,7]),[4,e.api.request({url:U?"aiApiUserQuotaPolicies:update/".concat(U.id):"aiApiUserQuotaPolicies:create",method:"post",data:n})];case 3:return i.sent(),l.message.success(t("Saved successfully")),x(!1),[4,C()];case 4:return i.sent(),[3,7];case 5:return a=i.sent(),l.message.error((0,u.g)(a)),[3,7];case 6:return k(!1),[7];case 7:return[2]}})})()},confirmLoading:S,destroyOnClose:!0},a().createElement(l.Form,{form:r,layout:"vertical",preserve:!1},a().createElement(l.Form.Item,{name:"userId",label:t("User"),rules:[{required:!0}]},a().createElement(l.Select,{disabled:!!U,showSearch:!0,optionFilterProp:"label",options:b.map(function(e){return{label:P(e),value:e.id}})})),a().createElement(l.Form.Item,{name:"periodType",label:t("Period"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Daily"),value:"daily"},{label:t("Monthly"),value:"monthly"}]})),a().createElement(l.Form.Item,{name:"timezone",label:t("Timezone"),rules:[{required:!0}]},a().createElement(l.Input,{placeholder:"UTC"})),a().createElement(l.Form.Item,{name:"requestLimit",label:t("Request limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"totalTokenLimit",label:t("Token limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"costLimit",label:t("Cost limit")},a().createElement(l.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),a().createElement(l.Form.Item,{name:"currency",label:t("Currency"),rules:[{required:!0}]},a().createElement(l.Input,null)),a().createElement(l.Form.Item,{name:"rejectUnpricedModel",label:t("Reject unpriced models"),valuePropName:"checked"},a().createElement(l.Switch,null)),a().createElement(l.Form.Item,{name:"missingUsageBehavior",label:t("Missing usage behavior"),rules:[{required:!0}]},a().createElement(l.Select,{options:[{label:t("Use reserved estimate"),value:"use_reserved"},{label:t("Allow without token charge"),value:"allow"}]})),a().createElement(l.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked"},a().createElement(l.Switch,null)))))}},235:function(e,t,r){r.d(t,{k:function(){return l}});var n=r(694),a=JSON.parse('{"UU":"plugin-ai-api"}');function l(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function a(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return a},m:function(){return n}})}}]);
@@ -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.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).push([["97"],{760:function(e,t,r){r.r(t),r.d(t,{default:function(){return g}});var n=r(155),o=r.n(n),i=r(59),l=r(185),a=r.n(l),u=r(694),c=r(235),s=r(630);function m(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 f(e,t,r,n,o,i,l){try{var a=e[i](l),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function l(e){f(i,n,o,l,a,"next",e)}function a(e){f(i,n,o,l,a,"throw",e)}l(void 0)})}}function p(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){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw n}}return i}}(e,t)||v(e,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.")}()}function v(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}function h(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function g(){var e=(0,u.useFlowContext)(),t=(0,c.k)(),r=b(i.Form.useForm(),1)[0],l=i.Form.useWatch("llmService",r),f=b((0,n.useState)([]),2),g=f[0],S=f[1],w=b((0,n.useState)([]),2),E=w[0],P=w[1],I=b((0,n.useState)([]),2),k=I[0],O=I[1],F=b((0,n.useState)(!1),2),M=F[0],x=F[1],j=b((0,n.useState)(!1),2),T=j[0],C=j[1],q=b((0,n.useState)(!1),2),A=q[0],D=q[1],_=b((0,n.useState)(),2),L=_[0],N=_[1],U=b((0,n.useState)(!1),2),B=U[0],R=U[1],V=(0,n.useCallback)(function(){return d(function(){var t,r,n,o;return h(this,function(l){switch(l.label){case 0:C(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,Promise.all([e.api.request({url:"aiApiModelPrices:list",method:"get",params:{pageSize:200,sort:"-effectiveFrom"}}),e.api.request({url:"ai:listLLMServices",method:"get"})])];case 2:return r=(t=b.apply(void 0,[l.sent(),2]))[0],n=t[1],S((0,s.m)(r,[])),P((0,s.m)(n,[])),[3,5];case 3:return o=l.sent(),i.message.error((0,s.g)(o)),[3,5];case 4:return C(!1),[7];case 5:return[2]}})})()},[e.api]);(0,n.useEffect)(function(){V()},[V]);var z=function(e){N(e),r.setFieldsValue(y(p({},e),{effectiveFrom:a()(e.effectiveFrom),effectiveTo:e.effectiveTo?a()(e.effectiveTo):void 0})),R(!0),G(e.llmService,e.model)},G=function(r,n){return d(function(){var o,l,a;return h(this,function(u){switch(u.label){case 0:x(!0),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,e.api.request({url:"ai:listModels",method:"get",params:{llmService:r}})];case 2:return o=u.sent(),l=(0,s.m)(o,[]),O(n&&!l.some(function(e){return e.id===n})?[{id:n}].concat(function(e){if(Array.isArray(e))return m(e)}(l)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||v(l)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):l),[3,5];case 3:return a=u.sent(),O(n?[{id:n}]:[]),i.message.error("".concat(t("Failed to load models"),": ").concat((0,s.g)(a))),[3,5];case 4:return x(!1),[7];case 5:return[2]}})})()},J=[{title:t("LLM service"),dataIndex:"llmService",key:"llmService",width:180},{title:t("Model"),dataIndex:"model",key:"model",width:180},{title:t("Input price / 1M"),dataIndex:"inputPricePerMillionTokens",key:"inputPrice",width:150},{title:t("Output price / 1M"),dataIndex:"outputPricePerMillionTokens",key:"outputPrice",width:150},{title:t("Fixed request cost"),dataIndex:"fixedCostPerRequest",key:"fixedCost",width:150},{title:t("Currency"),dataIndex:"currency",key:"currency",width:90},{title:t("Status"),dataIndex:"enabled",key:"enabled",width:100,render:function(e){return o().createElement(i.Tag,{color:e?"green":"default"},e?t("Enabled"):t("Disabled"))}},{title:t("Actions"),key:"actions",fixed:"right",width:150,render:function(r,n){return o().createElement(i.Space,null,o().createElement(i.Button,{type:"link",onClick:function(){return z(n)}},t("Edit")),o().createElement(i.Popconfirm,{title:t("Delete this price?"),onConfirm:function(){var r;return r=n.id,d(function(){var n;return h(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,e.api.request({url:"aiApiModelPrices:destroy/".concat(r),method:"post"})];case 1:return o.sent(),i.message.success(t("Deleted successfully")),[4,V()];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),i.message.error((0,s.g)(n)),[3,4];case 4:return[2]}})})()}},o().createElement(i.Button,{type:"link",danger:!0},t("Delete"))))}}];return o().createElement(i.Card,{title:t("Model pricing"),extra:o().createElement(i.Button,{type:"primary",onClick:function(){N(void 0),O([]),r.setFieldsValue({currency:"USD",inputPricePerMillionTokens:"0",outputPricePerMillionTokens:"0",fixedCostPerRequest:"0",effectiveFrom:a()(),enabled:!0}),R(!0)}},t("Add price"))},o().createElement(i.Table,{rowKey:"id",columns:J,dataSource:g,loading:T,scroll:{x:1200}}),o().createElement(i.Modal,{title:L?t("Edit price"):t("Add price"),open:B,onCancel:function(){return R(!1)},onOk:function(){return d(function(){var n,o,l,a,u,c,m;return h(this,function(f){switch(f.label){case 0:return[4,r.validateFields()];case 1:a=f.sent(),u=E.find(function(e){return e.name===a.llmService}),c=y(p({},a),{provider:null!=(n=null==u?void 0:u.provider)?n:a.provider,effectiveFrom:a.effectiveFrom.toISOString(),effectiveTo:null!=(o=null==(l=a.effectiveTo)?void 0:l.toISOString())?o:null}),D(!0),f.label=2;case 2:return f.trys.push([2,5,6,7]),[4,e.api.request({url:L?"aiApiModelPrices:update/".concat(L.id):"aiApiModelPrices:create",method:"post",data:c})];case 3:return f.sent(),i.message.success(t("Saved successfully")),R(!1),[4,V()];case 4:return f.sent(),[3,7];case 5:return m=f.sent(),i.message.error((0,s.g)(m)),[3,7];case 6:return D(!1),[7];case 7:return[2]}})})()},confirmLoading:A,destroyOnClose:!0},o().createElement(i.Form,{form:r,layout:"vertical",preserve:!1},o().createElement(i.Form.Item,{name:"llmService",label:t("LLM service"),rules:[{required:!0}]},o().createElement(i.Select,{showSearch:!0,optionFilterProp:"label",onChange:function(e){r.setFieldValue("model",void 0),O([]),G(e)},options:E.map(function(e){return{label:e.title||e.name,value:e.name}})})),o().createElement(i.Form.Item,{name:"provider",hidden:!0},o().createElement(i.Input,null)),o().createElement(i.Form.Item,{name:"model",label:t("Model"),rules:[{required:!0}]},o().createElement(i.Select,{showSearch:!0,optionFilterProp:"label",loading:M,disabled:!l,placeholder:t("Select a model"),options:k.map(function(e){return{label:e.id,value:e.id}})})),o().createElement(i.Form.Item,{name:"currency",label:t("Currency"),rules:[{required:!0}]},o().createElement(i.Input,null)),o().createElement(i.Form.Item,{name:"inputPricePerMillionTokens",label:t("Input price / 1M"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"outputPricePerMillionTokens",label:t("Output price / 1M"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"fixedCostPerRequest",label:t("Fixed request cost"),rules:[{required:!0}]},o().createElement(i.InputNumber,{min:0,stringMode:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"effectiveFrom",label:t("Effective from"),rules:[{required:!0}]},o().createElement(i.DatePicker,{showTime:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"effectiveTo",label:t("Effective to")},o().createElement(i.DatePicker,{showTime:!0,style:{width:"100%"}})),o().createElement(i.Form.Item,{name:"enabled",label:t("Enabled"),valuePropName:"checked"},o().createElement(i.Switch,null)),o().createElement(i.Form.Item,{name:"notes",label:t("Notes")},o().createElement(i.Input.TextArea,{rows:3})))))}},235:function(e,t,r){r.d(t,{k:function(){return i}});var n=r(694),o=JSON.parse('{"UU":"plugin-ai-api"}');function i(){var e=(0,n.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}},630:function(e,t,r){function n(e,t){var r,n;return e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?null!=(r=null==(n=e.data)?void 0:n.data)?r:t:t}function o(e){var t;return(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)?e.message:String(e)}r.d(t,{g:function(){return o},m:function(){return n}})}}]);
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd")):"function"==typeof define&&define.amd?define("plugin-ai-api/client-v2",["@nocobase/client-v2","react","antd"],t):"object"==typeof exports?exports["plugin-ai-api/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd")):e["plugin-ai-api/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd)}(self,function(e,t,n){return function(){"use strict";var r,o,i,a={485:function(t){t.exports=e},59:function(e){e.exports=n},155:function(e){e.exports=t}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return a[e](n,n.exports,c),n.exports}c.m=a,c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.f={},c.e=function(e){return Promise.all(Object.keys(c.f).reduce(function(t,n){return c.f[n](e,t),t},[]))},c.u=function(e){return""+e+".42b30b5cc9e32b8f.js"},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},c.l=function(e,t,n,r){if(l[e])return void l[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var p=a[u];if(p.getAttribute("src")==e||p.getAttribute("data-rspack")=="plugin-ai-api/client-v2:"+n){o=p;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,c.nc&&o.setAttribute("nonce",c.nc),o.setAttribute("data-rspack","plugin-ai-api/client-v2:"+n),o.src=e),l[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(p=c.g.location+"");var l,p,f=c.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var s=f.getElementsByTagName("script");if(s.length)for(var d=s.length-1;d>-1&&(!p||!/^http(s?):/.test(p));)p=s[d--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");c.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={889:0},c.f.j=function(e,t){var n=c.o(r,e)?r[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var o=new Promise(function(t,o){n=r[e]=[t,o]});t.push(n[2]=o);var i=c.p+c.u(e),a=Error();c.l(i,function(t){if(c.o(r,e)&&(0!==(n=r[e])&&(r[e]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}},"chunk-"+e,e)}},o=function(e,t){var n,o,i=t[0],a=t[1],u=t[2],l=0;if(i.some(function(e){return 0!==r[e]})){for(n in a)c.o(a,n)&&(c.m[n]=a[n]);u&&u(c)}for(e&&e(t);l<i.length;l++)o=i[l],c.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(i=self.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).forEach(o.bind(null,0)),i.push=o.bind(null,i.push.bind(i));var b={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-ai-api/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-ai-api/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-ai-api/dist/client-v2/"}c.p=e}(),!function(){c.r(b),c.d(b,{default:function(){return u}});var e=c(485);function t(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}c(155);function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var u=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={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),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"ai-api",title:this.t("AI API Gateway"),icon:"ApiOutlined",aclSnippet:"pm.ai-api.configuration"}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-api",key:"index",title:this.t("Configuration"),componentLoader:function(){return c.e("950").then(c.bind(c,693))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),b}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("plugin-ai-api/client-v2",["@nocobase/client-v2","dayjs","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["plugin-ai-api/client-v2"]=t(require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["plugin-ai-api/client-v2"]=t(e["@nocobase/client-v2"],e.dayjs,e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,a,u,c={485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=r},185:function(e){e.exports=t},155:function(e){e.exports=n}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e](n,n.exports,p),n.exports}p.m=c,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({302:"9b27a263901d54d8",757:"c377e2f2b054d89d",902:"d40d7bda106124c8",97:"fc922c37ced86831"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},p.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-ai-api/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","plugin-ai-api/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=f[e];if(delete f[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(s=p.g.location+"");var f,s,d=p.g.document;if(!s&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(s=d.currentScript.src),!s)){var b=d.getElementsByTagName("script");if(b.length)for(var g=b.length-1;g>-1&&(!s||!/^http(s?):/.test(s));)s=b[g--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");p.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},p.f.j=function(e,t){var n=p.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),a=Error();p.l(o,function(t){if(p.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,n[1](a)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],a=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==i[e]})){for(n in a)p.o(a,n)&&(p.m[n]=a[n]);u&&u(p)}for(e&&e(t);c<o.length;c++)r=o[c],p.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(u=self.webpackChunkplugin_ai_api_client_v2=self.webpackChunkplugin_ai_api_client_v2||[]).forEach(a.bind(null,0)),u.push=a.bind(null,u.push.bind(u));var h={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-ai-api/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-ai-api/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-ai-api/dist/client-v2/"}p.p=e}(),!function(){p.r(h),p.d(h,{default:function(){return u}});var e=p(485);function t(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var u=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={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),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"ai-api",title:this.t("AI API Gateway"),icon:"ApiOutlined",aclSnippet:"pm.ai-api.configuration"}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-api",key:"index",title:this.t("Configuration"),componentLoader:function(){return p.e("302").then(p.bind(p,581))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-api",key:"model-pricing",title:this.t("Model pricing"),componentLoader:function(){return p.e("97").then(p.bind(p,760))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-api",key:"user-quotas",title:this.t("User quotas"),componentLoader:function(){return p.e("902").then(p.bind(p,77))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-api",key:"usage",title:this.t("Usage"),componentLoader:function(){return p.e("757").then(p.bind(p,364))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),h}()});
@@ -10,15 +10,15 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "antd": "5.24.2",
13
- "@nocobase/client-v2": "2.1.30",
14
- "@nocobase/flow-engine": "2.1.30",
15
- "@nocobase/client": "2.1.30",
16
- "@nocobase/plugin-acl": "2.1.30",
17
- "@nocobase/server": "2.1.30",
13
+ "@nocobase/client-v2": "2.1.32",
14
+ "@nocobase/flow-engine": "2.1.32",
15
+ "@nocobase/client": "2.1.32",
16
+ "@nocobase/plugin-acl": "2.1.32",
17
+ "@nocobase/actions": "2.1.32",
18
18
  "dayjs": "1.11.13",
19
- "@nocobase/actions": "2.1.30",
20
- "@nocobase/database": "2.1.30",
19
+ "@nocobase/database": "2.1.32",
21
20
  "sequelize": "6.35.2",
22
- "@nocobase/resourcer": "2.1.30",
23
- "@nocobase/plugin-ai": "2.1.30"
21
+ "@nocobase/server": "2.1.32",
22
+ "@nocobase/resourcer": "2.1.32",
23
+ "@nocobase/plugin-ai": "2.1.32"
24
24
  };
@@ -6,5 +6,81 @@
6
6
  "Rate Limit": "Rate Limit",
7
7
  "Save Configuration": "Save Configuration",
8
8
  "Configuration saved": "Configuration saved",
9
- "Failed to save configuration": "Failed to save configuration"
10
- }
9
+ "Failed to save configuration": "Failed to save configuration",
10
+ "API mode": "API mode",
11
+ "Direct LLM": "Direct LLM",
12
+ "AI Employee agent": "AI Employee agent",
13
+ "Default LLM service": "Default LLM service",
14
+ "Enable user quotas": "Enable user quotas",
15
+ "Default reserved output tokens": "Default reserved output tokens",
16
+ "Refresh": "Refresh",
17
+ "Model pricing": "Model pricing",
18
+ "User quotas": "User quotas",
19
+ "Usage": "Usage",
20
+ "LLM service": "LLM service",
21
+ "Model": "Model",
22
+ "Input price / 1M": "Input price / 1M",
23
+ "Output price / 1M": "Output price / 1M",
24
+ "Fixed request cost": "Fixed request cost",
25
+ "Currency": "Currency",
26
+ "Status": "Status",
27
+ "Enabled": "Enabled",
28
+ "Disabled": "Disabled",
29
+ "Actions": "Actions",
30
+ "Edit": "Edit",
31
+ "Delete": "Delete",
32
+ "Delete this price?": "Delete this price?",
33
+ "Add price": "Add price",
34
+ "Edit price": "Edit price",
35
+ "Effective from": "Effective from",
36
+ "Effective to": "Effective to",
37
+ "Notes": "Notes",
38
+ "Saved successfully": "Saved successfully",
39
+ "Deleted successfully": "Deleted successfully",
40
+ "User": "User",
41
+ "Period": "Period",
42
+ "Request limit": "Request limit",
43
+ "Token limit": "Token limit",
44
+ "Cost limit": "Cost limit",
45
+ "Timezone": "Timezone",
46
+ "Unlimited": "Unlimited",
47
+ "Add quota": "Add quota",
48
+ "Edit quota": "Edit quota",
49
+ "Delete this quota?": "Delete this quota?",
50
+ "Daily": "Daily",
51
+ "Monthly": "Monthly",
52
+ "Reject unpriced models": "Reject unpriced models",
53
+ "Missing usage behavior": "Missing usage behavior",
54
+ "Use reserved estimate": "Use reserved estimate",
55
+ "Allow without token charge": "Allow without token charge",
56
+ "Started at": "Started at",
57
+ "Requested model": "Requested model",
58
+ "Resolved service": "Resolved service",
59
+ "Resolved model": "Resolved model",
60
+ "Input tokens": "Input tokens",
61
+ "Output tokens": "Output tokens",
62
+ "Total tokens": "Total tokens",
63
+ "Cost": "Cost",
64
+ "Cost status": "Cost status",
65
+ "Request ID": "Request ID",
66
+ "Failed to load models": "Failed to load models",
67
+ "Select a model": "Select a model",
68
+ "Select an AI Employee": "Select an AI Employee",
69
+ "Usage guide": "Usage guide",
70
+ "OpenAI-compatible endpoint": "OpenAI-compatible endpoint",
71
+ "Base URL": "Base URL",
72
+ "Use a NocoBase API key as the Bearer token.": "Use a NocoBase API key as the Bearer token.",
73
+ "List available models": "List available models",
74
+ "Send a chat completion": "Send a chat completion",
75
+ "Usage filters": "Usage filters",
76
+ "Time range": "Time range",
77
+ "User ID": "User ID",
78
+ "Succeeded": "Succeeded",
79
+ "Failed": "Failed",
80
+ "Started": "Started",
81
+ "Apply filters": "Apply filters",
82
+ "Reset": "Reset",
83
+ "Requests": "Requests",
84
+ "Total cost": "Total cost",
85
+ "Usage records": "Usage records"
86
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "AI API Gateway": "Cổng AI API",
3
+ "Configuration": "Cấu hình",
4
+ "Default AI Employee": "AI Employee mặc định",
5
+ "Enabled LLM Services": "Dịch vụ LLM được bật",
6
+ "Rate Limit": "Giới hạn tốc độ",
7
+ "Save Configuration": "Lưu cấu hình",
8
+ "Configuration saved": "Đã lưu cấu hình",
9
+ "Failed to save configuration": "Không thể lưu cấu hình",
10
+ "API mode": "Chế độ API",
11
+ "Direct LLM": "LLM trực tiếp",
12
+ "AI Employee agent": "AI Employee agent",
13
+ "Default LLM service": "Dịch vụ LLM mặc định",
14
+ "Enable user quotas": "Bật quota theo người dùng",
15
+ "Default reserved output tokens": "Số output token giữ chỗ mặc định",
16
+ "Refresh": "Làm mới",
17
+ "Model pricing": "Bảng giá model",
18
+ "User quotas": "Quota người dùng",
19
+ "Usage": "Lịch sử sử dụng",
20
+ "LLM service": "Dịch vụ LLM",
21
+ "Model": "Model",
22
+ "Input price / 1M": "Giá input / 1 triệu token",
23
+ "Output price / 1M": "Giá output / 1 triệu token",
24
+ "Fixed request cost": "Chi phí cố định mỗi request",
25
+ "Currency": "Tiền tệ",
26
+ "Status": "Trạng thái",
27
+ "Enabled": "Đang bật",
28
+ "Disabled": "Đã tắt",
29
+ "Actions": "Thao tác",
30
+ "Edit": "Sửa",
31
+ "Delete": "Xóa",
32
+ "Delete this price?": "Xóa cấu hình giá này?",
33
+ "Add price": "Thêm giá",
34
+ "Edit price": "Sửa giá",
35
+ "Effective from": "Hiệu lực từ",
36
+ "Effective to": "Hiệu lực đến",
37
+ "Notes": "Ghi chú",
38
+ "Saved successfully": "Đã lưu thành công",
39
+ "Deleted successfully": "Đã xóa thành công",
40
+ "User": "Người dùng",
41
+ "Period": "Chu kỳ",
42
+ "Request limit": "Giới hạn request",
43
+ "Token limit": "Giới hạn token",
44
+ "Cost limit": "Giới hạn chi phí",
45
+ "Timezone": "Múi giờ",
46
+ "Unlimited": "Không giới hạn",
47
+ "Add quota": "Thêm quota",
48
+ "Edit quota": "Sửa quota",
49
+ "Delete this quota?": "Xóa quota này?",
50
+ "Daily": "Hàng ngày",
51
+ "Monthly": "Hàng tháng",
52
+ "Reject unpriced models": "Từ chối model chưa có giá",
53
+ "Missing usage behavior": "Xử lý khi thiếu token usage",
54
+ "Use reserved estimate": "Dùng số liệu giữ chỗ để ước tính",
55
+ "Allow without token charge": "Cho phép và không tính token",
56
+ "Started at": "Bắt đầu lúc",
57
+ "Requested model": "Model được yêu cầu",
58
+ "Resolved service": "Service đã resolve",
59
+ "Resolved model": "Model đã resolve",
60
+ "Input tokens": "Input token",
61
+ "Output tokens": "Output token",
62
+ "Total tokens": "Tổng token",
63
+ "Cost": "Chi phí",
64
+ "Cost status": "Trạng thái chi phí",
65
+ "Request ID": "Request ID",
66
+ "Failed to load models": "Không thể tải danh sách model",
67
+ "Select a model": "Chọn model",
68
+ "Select an AI Employee": "Chọn AI Employee",
69
+ "Usage guide": "Hướng dẫn sử dụng",
70
+ "OpenAI-compatible endpoint": "Endpoint tương thích OpenAI",
71
+ "Base URL": "Base URL",
72
+ "Use a NocoBase API key as the Bearer token.": "Sử dụng NocoBase API key làm Bearer token.",
73
+ "List available models": "Liệt kê model khả dụng",
74
+ "Send a chat completion": "Gửi yêu cầu chat completion",
75
+ "Usage filters": "Bộ lọc usage",
76
+ "Time range": "Khoảng thời gian",
77
+ "User ID": "User ID",
78
+ "Succeeded": "Thành công",
79
+ "Failed": "Thất bại",
80
+ "Started": "Đã bắt đầu",
81
+ "Apply filters": "Áp dụng bộ lọc",
82
+ "Reset": "Đặt lại",
83
+ "Requests": "Số request",
84
+ "Total cost": "Tổng chi phí",
85
+ "Usage records": "Chi tiết usage"
86
+ }