@cloudbase/js-sdk
Version:
cloudbase javascript sdk
2 lines • 828 kB
JavaScript
/*! For license information please see index.node.cjs.js.LICENSE.txt */
(()=>{var e,t,n={9954:(e,t,n)=>{e.exports={parallel:n(8197),serial:n(8967),serialOrdered:n(982)}},190:e=>{function t(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}e.exports=function(e){Object.keys(e.jobs).forEach(t.bind(e)),e.jobs={}}},1307:(e,t,n)=>{var r=n(8765);e.exports=function(e){var t=!1;return r(function(){t=!0}),function(n,o){t?e(n,o):r(function(){e(n,o)})}}},8765:e=>{e.exports=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)}},5798:(e,t,n)=>{var r=n(1307),o=n(190);e.exports=function(e,t,n,i){var a=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[a]=function(e,t,n,o){return 2==e.length?e(n,r(o)):e(n,t,r(o))}(t,a,e[a],function(e,t){a in n.jobs&&(delete n.jobs[a],e?o(n):n.results[a]=t,i(e,n.results))})}},7379:e=>{e.exports=function(e,t){var n=!Array.isArray(e),r={index:0,keyedList:n||t?Object.keys(e):null,jobs:{},results:n?{}:[],size:n?Object.keys(e).length:e.length};return t&&r.keyedList.sort(n?t:function(n,r){return t(e[n],e[r])}),r}},3797:(e,t,n)=>{var r=n(190),o=n(1307);e.exports=function(e){Object.keys(this.jobs).length&&(this.index=this.size,r(this),o(e)(null,this.results))}},8197:(e,t,n)=>{var r=n(5798),o=n(7379),i=n(3797);e.exports=function(e,t,n){for(var a=o(e);a.index<(a.keyedList||e).length;)r(e,t,a,function(e,t){e?n(e,t):0!==Object.keys(a.jobs).length||n(null,a.results)}),a.index++;return i.bind(a,n)}},8967:(e,t,n)=>{var r=n(982);e.exports=function(e,t,n){return r(e,t,null,n)}},982:(e,t,n)=>{var r=n(5798),o=n(7379),i=n(3797);function a(e,t){return e<t?-1:e>t?1:0}e.exports=function(e,t,n,a){var s=o(e,n);return r(e,t,s,function n(o,i){o?a(o,i):(s.index++,s.index<(s.keyedList||e).length?r(e,t,s,n):a(null,s.results))}),i.bind(s,a)},e.exports.ascending=a,e.exports.descending=function(e,t){return-1*a(e,t)}},7756:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var u=n(9737),l=a(n(5305)),p=n(1689),d=n(2877),f=l.MODELS,h=function(){function e(e,t,n,o){var i=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,n=e.data,o=e.headers,a=e.stream,u=e.timeout;return s(i,void 0,void 0,function(){var e,i,s,l,p,d,f;return c(this,function(c){switch(c.label){case 0:return e={"Content-Type":"application/json"},a&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:r(r((p={},p[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,p),e),o),body:JSON.stringify(n),url:this.resolveUrl(t),stream:a,timeout:u})];case 1:return i=c.sent(),s=i.data,l=i.header,[2,this.handleResponseData(s,l)]}})})},this.botRequest=function(e){var t=e.method,n=e.url,o=e.data,a=void 0===o?{}:o,u=e.headers,l=e.stream,p=e.timeout;return s(i,void 0,void 0,function(){var e,o,i,s,d,f,h,m,v;return c(this,function(c){switch(c.label){case 0:return e=this.resolveUrl(n),"get"!==t?[3,2]:(o=this.handleResponseData,[4,this.req.fetch({url:"".concat(e,"?").concat((y=a,Object.entries(y).map(function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)}).join("&"))),method:t,headers:u,stream:l,timeout:p})]);case 1:return[2,o.apply(this,[c.sent().data])];case 2:return i={"Content-Type":"application/json"},l&&Object.assign(i,{Accept:"text/event-stream"}),[4,this.req.fetch({url:e,body:JSON.stringify(a),headers:r(r((h={},h[null===(m=this.i18n)||void 0===m?void 0:m.LANG_HEADER_KEY]=null===(v=this.i18n)||void 0===v?void 0:v.lang,h),i),u),stream:l,method:t,timeout:p})];case 3:return s=c.sent(),d=s.data,f=s.header,[2,this.handleResponseData(d,f)]}var y})})},this._getBaseUrl=o,this.bot=new u.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=n,d.langEvent.bus.on(d.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return Object.defineProperty(e.prototype,"aiBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/ai")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aiBotBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/aibot")},enumerable:!1,configurable:!0}),e.prototype.handleResponseData=function(e,t){var n,r;return s(this,void 0,void 0,function(){var o,i,a,s,u=this;return c(this,function(c){switch(c.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),i=function(e){if("object"==typeof e&&e&&"code"in e&&"NORMAL"!==e.code)throw new Error("".concat(u.i18n.t("AI+ 请求出错,错误码"),":").concat(e.code,",").concat(u.i18n.t("错误信息"),":").concat(e.message,"\n").concat(o,"\n").concat(JSON.stringify(e,null,2)))},"object"==typeof e&&e&&"function"!=typeof e.getReader?"then"in e?[4,e]:[3,2]:[3,4];case 1:return a=c.sent(),[3,3];case 2:a=e,c.label=3;case 3:return i(s=a),[2,e];case 4:if("function"!=typeof(null==e?void 0:e.getReader)){if("object"==typeof(s=e)&&s&&"code"in s&&"NORMAL"!==s.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(s.code,",").concat(this.i18n.t("错误信息"),":").concat(s.message,"\n").concat(o,"\n").concat(JSON.stringify(s,null,2)));return[2,e]}return(null===(r=null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(t,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,(0,p.readableStream2JsonObject)(e)]:[3,6];case 5:s=c.sent(),i(s),c.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var n,r=f[e];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";n=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new l.ReactModel(n)},e.prototype.registerModel=function(e,t){null==f[e]?f[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new l.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){l.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),l.toolMap.set(e.name,e.fn)},e.prototype.resolveUrl=function(e){if(!this._getBaseUrl)return e;var t=this._getBaseUrl();return t!==this.baseUrl&&e.startsWith(this.baseUrl)?e.replace(this.baseUrl,t):e},e}();t.AI=h},9737:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var s=n(1689),c=function(){function e(e,t){this.baseUrl=t;var n=arguments[2];this.req="string"==typeof n?function(t){var o=t.headers,i=void 0===o?{}:o,s=a(t,["headers"]);return e(r(r({},s),{headers:r(r({},i),{Authorization:"Bearer ".concat(n)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var n=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var n=e.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var n=e.botId,r=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var n=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var n=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.createConversation=function(e,t){var n=e.botId,r=a(e,["botId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getConversation=function(e,t){var n=e.pageSize,s=void 0===n?10:n,c=e.pageNumber,u=void 0===c?1:c,l=e.botId,p=a(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,n;return i(this,function(o){if(u<1)throw new Error("pageNumber must be greater than 0");return e=s*(u-1),n=s,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:r(r({},p),{offset:e,limit:n}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var n=e.botId,r=e.conversationId,s=a(e,["botId","conversationId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:s,timeout:null==t?void 0:t.timeout})]})})},e.prototype.speechToText=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.textToSpeech=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getTextToSpeechResult=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getRecommendQuestions=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=c;var u=function(){function e(e){var t=(0,s.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new s.TextDecoderStream).pipeThrough((0,s.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],n=e[1];return this._eventSourceStream=n,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,s.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,s.createAsyncIterable)(this.eventSourceStream.pipeThrough(new s.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,s.createAsyncIterable)(this.dataStream.pipeThrough(new s.TransformStream({transform:function(e,t){var n;t.enqueue(null!==(n=null==e?void 0:e.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),e}()},713:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidParamsError=void 0;var o=function(e){function t(t,n){var r=e.call(this,t)||this;return r.name="InvalidParamsError",r.code="INVALID_PARAMS",r.field=n,r}return r(t,e),t.prototype.toJSON=function(){return{code:this.code,message:this.message,field:this.field}},t}(Error);t.InvalidParamsError=o},9964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var r=n(6298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return r.createParser}})},6298:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,r,o,i,a,s,c;return u(),{feed:function(e){r=r?r+e:e,t&&function(e){return n.every(function(t,n){return e.charCodeAt(n)===t})}(r)&&(r=r.slice(n.length)),t=!1;for(var a=r.length,s=0,c=!1;s<a;){c&&("\n"===r[s]&&(s+=1),c=!1);for(var u=-1,p=i,d=void 0,f=o;u<0&&f<a;f++)":"===(d=r[f])&&p<0?p=f-s:"\r"===d?(c=!0,u=f-s):"\n"===d&&(u=f-s);if(u<0){o=a-s,i=p;break}o=0,i=-1,l(r,s,p,u),s+=u+1}s===a?r="":s>0&&(r=r.slice(s))},reset:u};function u(){t=!0,r="",o=0,i=-1,a=void 0,s=void 0,c=""}function l(t,n,r,o){if(0===o)return c.length>0&&(e({type:"event",id:a,event:s||void 0,data:c.slice(0,-1)}),c="",a=void 0),void(s=void 0);var i,u=r<0,l=t.slice(n,n+(u?o:r)),p=n+(i=u?o:" "===t[n+r+1]?r+2:r+1),d=o-i,f=t.slice(p,p+d).toString();if("data"===l)c+=f?"".concat(f,"\n"):"\n";else if("event"===l)s=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var h=parseInt(f,10);Number.isNaN(h)||e({type:"reconnect-interval",value:h})}}else a=f}};var n=[239,187,191]},5337:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},c=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var p=n(7756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return p.AI}});var d=n(9737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return d.Bot}});var f=a(n(5305)),h=a(n(1689));t.utils=h,f.MODELS;var m=l(f,["MODELS"]);function v(e){var t=e.env,n=e.baseUrl,o=e.getBaseUrl,i=e.req,a=e.getAccessToken,s=e.handleReqInstance,d=e.i18n;return new p.AI(function(){if(null==s){if(null==a)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,n=e.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(e){return c(void 0,void 0,void 0,function(){var o,i,a,s,c;return u(this,function(u){switch(u.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,a=void 0===i?{}:i,s=l(e,["token","headers"]),null==o?[3,1]:(c=o,[3,3]);case 1:return[4,t()];case 2:c=u.sent().accessToken,u.label=3;case 3:return[2,n.fetch(r({headers:r({Authorization:"Bearer ".concat(c)},a)},s))]}})})}}}({req:i,getAccessToken:a})}return s({req:i})}(),function(){if(null!=o)return o();if(null!=n)return n;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),d,o)}t.models=m,t.createAI=v;var y=v;t.createAi=y;var g={name:"ai",entity:{ai:function(e){var t=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var r=function(){var e=t.getEndPointWithKey("GATEWAY"),n=e.BASE_URL,r=e.PROTOCOL;return"".concat(r).concat(n)};return(null==e?void 0:e.baseUrl)?v({req:n,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):v({req:n,baseUrl:r(),getBaseUrl:r,handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function b(e){try{e.registerComponent(g)}catch(e){console.warn(e)}}t.registerAi=b,s(n(4669),t),s(n(713),t);try{window.registerAi=b}catch(e){}},5476:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var a=n(1689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(c),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}})})},e}();t.ArkSimpleModel=c},7265:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var a=n(1689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(c),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}})})},e}();t.DSSimpleModel=c},2102:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var a=n(1689),s=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,s,c,u;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),s=(0,a.toPolyfillReadable)(o),c=(0,a.intoStandardStream)(s),u=c.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(u)]}})})},e}();t.DeepSeekSimpleModel=s},8017:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var a=n(1689),s=function(){function e(e,t,n){void 0===n&&(n=""),this.req=e,this.baseUrl=t,this.subUrl=n}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,s,c;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,a.toPolyfillReadable)(n),s=(0,a.intoStandardStream)(o),c=s.pipeThrough(new a.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,a.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}})})},e}();t.DefaultSimpleModel=s},7239:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var a=n(1689),s=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=(0,s.titleCaseToSnakeCase)(n.Response),[2,r(r({},o),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(c),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=(0,s.titleCaseToSnakeCase)(e),i=o.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),c=r(r({},o),{choices:i});t.enqueue(r(r({},c),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}})})},e}();t.HunYuanSimpleModel=c},8586:function(e,t){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,a=e.tools,s=e.top_p;return n(n({},e),{messages:(t.forEach(function(e){"tool_calls"in e&&e.tool_calls.filter(function(e){return"function"!==e.type}).forEach(function(t){return console.warn("`type` in tool_call is not 'function'",t,e)})}),t),model:r,tools:function(){if(a)return a.forEach(function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)}),a}(),top_p:s,tool_choice:i,temperature:o})},t.titleCaseToSnakeCase=function e(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map(function(t){return e(t)}):Object.entries(t).reduce(function(t,n){var r,o=n[0],i=n[1];return t["_"===(r=o.replace(/[A-Z]/g,function(e){return"_".concat(e.toLowerCase())})).charAt(0)?r.slice(1):r]="object"==typeof i?e(i):i,t},{})}},9301:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var a=n(1689),s=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(c),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}})})},e}();t.HunYuanBetaSimpleModel=c},5720:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var a=n(1689),s=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,c,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,a.toPolyfillReadable)(n),c=(0,a.intoStandardStream)(o),u=c.pipeThrough(new a.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,a.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(u)]}})})},e}();t.HunYuanExpSimpleModel=c},1586:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var a=n(1689),s=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(c),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{raw