UNPKG

@cloudbase/js-sdk

Version:
2 lines 610 kB
/*! For license information please see index.cjs.js.LICENSE.txt */ !function(){var e,t,r={7756:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var c=r(9737),l=s(r(5305)),d=r(1689),h=r(2877),f=l.MODELS,p=function(){function e(e,t,r,o){var i=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,r=e.data,o=e.headers,s=e.stream,c=e.timeout;return a(i,void 0,void 0,function(){var e,i,a,l,d,h,f;return u(this,function(u){switch(u.label){case 0:return e={"Content-Type":"application/json"},s&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:n(n((d={},d[null===(h=this.i18n)||void 0===h?void 0:h.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,d),e),o),body:JSON.stringify(r),url:this.resolveUrl(t),stream:s,timeout:c})];case 1:return i=u.sent(),a=i.data,l=i.header,[2,this.handleResponseData(a,l)]}})})},this.botRequest=function(e){var t=e.method,r=e.url,o=e.data,s=void 0===o?{}:o,c=e.headers,l=e.stream,d=e.timeout;return a(i,void 0,void 0,function(){var e,o,i,a,h,f,p,v,y;return u(this,function(u){switch(u.label){case 0:return e=this.resolveUrl(r),"get"!==t?[3,2]:(o=this.handleResponseData,[4,this.req.fetch({url:"".concat(e,"?").concat((m=s,Object.entries(m).map(function(e){var t=e[0],r=e[1];return"".concat(t,"=").concat(r)}).join("&"))),method:t,headers:c,stream:l,timeout:d})]);case 1:return[2,o.apply(this,[u.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(s),headers:n(n((p={},p[null===(v=this.i18n)||void 0===v?void 0:v.LANG_HEADER_KEY]=null===(y=this.i18n)||void 0===y?void 0:y.lang,p),i),c),stream:l,method:t,timeout:d})];case 3:return a=u.sent(),h=a.data,f=a.header,[2,this.handleResponseData(h,f)]}var m})})},this._getBaseUrl=o,this.bot=new c.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=r,h.langEvent.bus.on(h.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 r,n;return a(this,void 0,void 0,function(){var o,i,s,a,c=this;return u(this,function(u){switch(u.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(c.i18n.t("AI+ 请求出错,错误码"),":").concat(e.code,",").concat(c.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 s=u.sent(),[3,3];case 2:s=e,u.label=3;case 3:return i(a=s),[2,e];case 4:if("function"!=typeof(null==e?void 0:e.getReader)){if("object"==typeof(a=e)&&a&&"code"in a&&"NORMAL"!==a.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(a.code,",").concat(this.i18n.t("错误信息"),":").concat(a.message,"\n").concat(o,"\n").concat(JSON.stringify(a,null,2)));return[2,e]}return(null===(n=null===(r=null==t?void 0:t.get)||void 0===r?void 0:r.call(t,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,(0,d.readableStream2JsonObject)(e)]:[3,6];case 5:a=u.sent(),i(a),u.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var r,n=f[e];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";r=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new l.ReactModel(r)},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=p},9737:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var a=r(1689),u=function(){function e(e,t){this.baseUrl=t;var r=arguments[2];this.req="string"==typeof r?function(t){var o=t.headers,i=void 0===o?{}:o,a=s(t,["headers"]);return e(n(n({},a),{headers:n(n({},i),{Authorization:"Bearer ".concat(r)})}))}: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 r=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var r=e.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var r=e.botId,n=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var r=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),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 r=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,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(r){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 r=e.botId,n=s(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(r,"/conversation")),data:n,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getConversation=function(e,t){var r=e.pageSize,a=void 0===r?10:r,u=e.pageNumber,c=void 0===u?1:u,l=e.botId,d=s(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,r;return i(this,function(o){if(c<1)throw new Error("pageNumber must be greater than 0");return e=a*(c-1),r=a,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:n(n({},d),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=e.conversationId,a=s(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(r,"/conversation/").concat(n)),data:a,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(r){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(r){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(r){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 r;return i(this,function(n){switch(n.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 r=n.sent(),[2,new c(r)]}})})},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.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 r=n.sent(),[2,new c(r)]}})})},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.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 r=n.sent(),[2,new c(r)]}})})},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 r;return i(this,function(n){switch(n.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 r=n.sent(),[2,new c(r)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=u;var c=function(){function e(e){var t=(0,a.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new a.TextDecoderStream).pipeThrough((0,a.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],r=e[1];return this._eventSourceStream=r,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,a.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,a.createAsyncIterable)(this.eventSourceStream.pipeThrough(new a.TransformStream({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,a.createAsyncIterable)(this.dataStream.pipeThrough(new a.TransformStream({transform:function(e,t){var r;t.enqueue(null!==(r=null==e?void 0:e.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),e}()},713:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(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 n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidParamsError=void 0;var o=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="InvalidParamsError",n.code="INVALID_PARAMS",n.field=r,n}return n(t,e),t.prototype.toJSON=function(){return{code:this.code,message:this.message,field:this.field}},t}(Error);t.InvalidParamsError=o},9964:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var n=r(6298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return n.createParser}})},6298:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,n,o,i,s,a,u;return c(),{feed:function(e){n=n?n+e:e,t&&function(e){return r.every(function(t,r){return e.charCodeAt(r)===t})}(n)&&(n=n.slice(r.length)),t=!1;for(var s=n.length,a=0,u=!1;a<s;){u&&("\n"===n[a]&&(a+=1),u=!1);for(var c=-1,d=i,h=void 0,f=o;c<0&&f<s;f++)":"===(h=n[f])&&d<0?d=f-a:"\r"===h?(u=!0,c=f-a):"\n"===h&&(c=f-a);if(c<0){o=s-a,i=d;break}o=0,i=-1,l(n,a,d,c),a+=c+1}a===s?n="":a>0&&(n=n.slice(a))},reset:c};function c(){t=!0,n="",o=0,i=-1,s=void 0,a=void 0,u=""}function l(t,r,n,o){if(0===o)return u.length>0&&(e({type:"event",id:s,event:a||void 0,data:u.slice(0,-1)}),u="",s=void 0),void(a=void 0);var i,c=n<0,l=t.slice(r,r+(c?o:n)),d=r+(i=c?o:" "===t[r+n+1]?n+2:n+1),h=o-i,f=t.slice(d,d+h).toString();if("data"===l)u+=f?"".concat(f,"\n"):"\n";else if("event"===l)a=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var p=parseInt(f,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else s=f}};var r=[239,187,191]},5337:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var d=r(7756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return d.AI}});var h=r(9737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return h.Bot}});var f=s(r(5305)),p=s(r(1689));t.utils=p,f.MODELS;var v=l(f,["MODELS"]);function y(e){var t=e.env,r=e.baseUrl,o=e.getBaseUrl,i=e.req,s=e.getAccessToken,a=e.handleReqInstance,h=e.i18n;return new d.AI(function(){if(null==a){if(null==s)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,r=e.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(e){return u(void 0,void 0,void 0,function(){var o,i,s,a,u;return c(this,function(c){switch(c.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,s=void 0===i?{}:i,a=l(e,["token","headers"]),null==o?[3,1]:(u=o,[3,3]);case 1:return[4,t()];case 2:u=c.sent().accessToken,c.label=3;case 3:return[2,r.fetch(n({headers:n({Authorization:"Bearer ".concat(u)},s)},a))]}})})}}}({req:i,getAccessToken:s})}return a({req:i})}(),function(){if(null!=o)return o();if(null!=r)return r;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),h,o)}t.models=v,t.createAI=y;var m=y;t.createAi=m;var g={name:"ai",entity:{ai:function(e){var t=this,r=this.request;if(null==r.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var n=function(){var e=t.getEndPointWithKey("GATEWAY"),r=e.BASE_URL,n=e.PROTOCOL;return"".concat(n).concat(r)};return(null==e?void 0:e.baseUrl)?y({req:r,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):y({req:r,baseUrl:n(),getBaseUrl:n,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,a(r(4669),t),a(r(713),t);try{window.registerAi=b}catch(e){}},5476:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}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 r;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.ArkSimpleModel=u},7265:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}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 r;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),n(n({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})}),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.DSSimpleModel=u},2102:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var s=r(1689),a=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}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 r;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,a,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),a=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(a),c=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}})})},e}();t.DeepSeekSimpleModel=a},8017:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var s=r(1689),a=function(){function e(e,t,r){void 0===r&&(r=""),this.req=e,this.baseUrl=t,this.subUrl=r}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(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:n(n({},e),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,n(n({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,r,o,a,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},e),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,s.toPolyfillReadable)(r),a=(0,s.intoStandardStream)(o),u=a.pipeThrough(new s.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(r)),t?n(n({},e),{finish_reason:"tool_calls",delta:r}):e}),i=n(n({},e),{choices:o});r.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}})})},e}();t.DefaultSimpleModel=a},7239:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}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 r,o;return i(this,function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=i.sent(),o=(0,a.titleCaseToSnakeCase)(r.Response),[2,n(n({},o),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:n(n({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=(0,a.titleCaseToSnakeCase)(e),i=o.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),u=n(n({},o),{choices:i});t.enqueue(n(n({},u),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanSimpleModel=u},8586:function(e,t){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return r(r({},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:n,tools:function(){if(s)return s.forEach(function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)}),s}(),top_p:a,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,r){var n,o=r[0],i=r[1];return t["_"===(n=o.replace(/[A-Z]/g,function(e){return"_".concat(e.toLowerCase())})).charAt(0)?n.slice(1):n]="object"==typeof i?e(i):i,t},{})}},9301:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}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 r;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanBetaSimpleModel=u},5720:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}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(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,n(n({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,r,o,u,c;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,s.toPolyfillReadable)(r),u=(0,s.intoStandardStream)(o),c=u.pipeThrough(new s.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(r)),t?n(n({},e),{finish_reason:"tool_calls",delta:r}):e}),i=n(n({},e),{choices:o});r.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}})})},e}();t.HunYuanExpSimpleModel=u},1586:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}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 r;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var r,o,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanOpenSimpleModel=u},3925:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleMod