@cloudbase/js-sdk
Version:
cloudbase javascript sdk
2 lines • 184 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_ai",[],t):"object"==typeof exports?exports.cloudbase_ai=t():e.cloudbase_ai=t()}("undefined"!=typeof window?window:this,()=>(()=>{var e={829:(e,t,r)=>{"use strict";var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>a}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},756: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}),a=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},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},l=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var u=r(737),c=a(r(305)),f=r(689),d=r(877),h=c.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,a=e.stream,u=e.timeout;return s(i,void 0,void 0,function(){var e,i,s,c,f,d,h;return l(this,function(l){switch(l.label){case 0:return e={"Content-Type":"application/json"},a&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:n(n((f={},f[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),e),o),body:JSON.stringify(r),url:this.resolveUrl(t),stream:a,timeout:u})];case 1:return i=l.sent(),s=i.data,c=i.header,[2,this.handleResponseData(s,c)]}})})},this.botRequest=function(e){var t=e.method,r=e.url,o=e.data,a=void 0===o?{}:o,u=e.headers,c=e.stream,f=e.timeout;return s(i,void 0,void 0,function(){var e,o,i,s,d,h,p,b,m;return l(this,function(l){switch(l.label){case 0:return e=this.resolveUrl(r),"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],r=e[1];return"".concat(t,"=").concat(r)}).join("&"))),method:t,headers:u,stream:c,timeout:f})]);case 1:return[2,o.apply(this,[l.sent().data])];case 2:return i={"Content-Type":"application/json"},c&&Object.assign(i,{Accept:"text/event-stream"}),[4,this.req.fetch({url:e,body:JSON.stringify(a),headers:n(n((p={},p[null===(b=this.i18n)||void 0===b?void 0:b.LANG_HEADER_KEY]=null===(m=this.i18n)||void 0===m?void 0:m.lang,p),i),u),stream:c,method:t,timeout:f})];case 3:return s=l.sent(),d=s.data,h=s.header,[2,this.handleResponseData(d,h)]}var y})})},this._getBaseUrl=o,this.bot=new u.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=r,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 r,n;return s(this,void 0,void 0,function(){var o,i,a,s,u=this;return l(this,function(l){switch(l.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=l.sent(),[3,3];case 2:a=e,l.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===(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,f.readableStream2JsonObject)(e)]:[3,6];case 5:s=l.sent(),i(s),l.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var r,n=h[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 c.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new c.ReactModel(r)},e.prototype.registerModel=function(e,t){null==h[e]?h[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new c.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){c.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),c.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},737: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},a=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 s=r(689),l=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,s=a(t,["headers"]);return e(n(n({},s),{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=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(r,"/conversation")),data:n,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getConversation=function(e,t){var r=e.pageSize,s=void 0===r?10:r,l=e.pageNumber,u=void 0===l?1:l,c=e.botId,f=a(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,r;return i(this,function(o){if(u<1)throw new Error("pageNumber must be greater than 0");return e=s*(u-1),r=s,[2,this.req({method:"get",url:this.join("bots/".concat(c,"/conversation")),data:n(n({},f),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=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(r,"/conversation/").concat(n)),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(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 u(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 u(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 u(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 u(r)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=l;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],r=e[1];return this._eventSourceStream=r,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 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,s.createAsyncIterable)(this.dataStream.pipeThrough(new s.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},964:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var n=r(298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return n.createParser}})},298:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,n,o,i,a,s,l;return u(),{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 a=n.length,s=0,l=!1;s<a;){l&&("\n"===n[s]&&(s+=1),l=!1);for(var u=-1,f=i,d=void 0,h=o;u<0&&h<a;h++)":"===(d=n[h])&&f<0?f=h-s:"\r"===d?(l=!0,u=h-s):"\n"===d&&(u=h-s);if(u<0){o=a-s,i=f;break}o=0,i=-1,c(n,s,f,u),s+=u+1}s===a?n="":s>0&&(n=n.slice(s))},reset:u};function u(){t=!0,n="",o=0,i=-1,a=void 0,s=void 0,l=""}function c(t,r,n,o){if(0===o)return l.length>0&&(e({type:"event",id:a,event:s||void 0,data:l.slice(0,-1)}),l="",a=void 0),void(s=void 0);var i,u=n<0,c=t.slice(r,r+(u?o:n)),f=r+(i=u?o:" "===t[r+n+1]?n+2:n+1),d=o-i,h=t.slice(f,f+d).toString();if("data"===c)l+=h?"".concat(h,"\n"):"\n";else if("event"===c)s=h;else if("id"!==c||h.includes("\0")){if("retry"===c){var p=parseInt(h,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else a=h}};var r=[239,187,191]},337: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}),a=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},s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},l=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},c=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 f=r(756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return f.AI}});var d=r(737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return d.Bot}});var h=a(r(305)),p=a(r(689));t.utils=p,h.MODELS;var b=c(h,["MODELS"]);function m(e){var t=e.env,r=e.baseUrl,o=e.getBaseUrl,i=e.req,a=e.getAccessToken,s=e.handleReqInstance,d=e.i18n;return new f.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,r=e.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(e){return l(void 0,void 0,void 0,function(){var o,i,a,s,l;return u(this,function(u){switch(u.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,a=void 0===i?{}:i,s=c(e,["token","headers"]),null==o?[3,1]:(l=o,[3,3]);case 1:return[4,t()];case 2:l=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(n({headers:n({Authorization:"Bearer ".concat(l)},a)},s))]}})})}}}({req:i,getAccessToken:a})}return s({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")}(),d,o)}t.models=b,t.createAI=m;var y=m;t.createAi=y;var v={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)?m({req:r,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):m({req:r,baseUrl:n(),getBaseUrl:n,handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function _(e){try{e.registerComponent(v)}catch(e){console.warn(e)}}t.registerAi=_,s(r(669),t),s(r(713),t);try{window.registerAi=_}catch(e){}},476: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.ArkSimpleModel=l},265: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=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==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.DSSimpleModel=l},102: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var a=r(689),s=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,s,l,u;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(),s=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(s),u=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(u)]}})})},e}();t.DeepSeekSimpleModel=s},17: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var a=r(689),s=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,s,l;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,a.toPolyfillReadable)(r),s=(0,a.intoStandardStream)(o),l=s.pipeThrough(new a.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,a.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,a.createAsyncIterable)(l)]}})})},e}();t.DefaultSimpleModel=s},239: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=i.sent(),o=(0,s.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,l,u,c;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(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=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==r&&(r=(0,a.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),l=n(n({},o),{choices:i});t.enqueue(n(n({},l),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanSimpleModel=l},586: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,a=e.tools,s=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(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,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},{})}},301: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanBetaSimpleModel=l},720: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,a.toPolyfillReadable)(r),l=(0,a.intoStandardStream)(o),u=l.pipeThrough(new a.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,a.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,a.createAsyncIterable)(u)]}})})},e}();t.HunYuanExpSimpleModel=l},418: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanOpenSimpleModel=l},925: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,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(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:cas