@difizen/magent-au
Version:
175 lines • 8.91 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3, _dec5, _dec6, _dec7, _dec8, _class3, _class4, _descriptor4, _descriptor5, _descriptor6;
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
import { inject, prop, transient } from '@difizen/mana-app';
import { LLMProviderOption } from "./protocol.js";
import { LLMModelOption } from "./protocol.js";
export var LLMProvider = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
function LLMProvider(_meta) {
var _this = this;
_classCallCheck(this, LLMProvider);
this.id = void 0;
_initializerDefineProperty(this, "nickname", _descriptor, this);
_initializerDefineProperty(this, "model_name", _descriptor2, this);
_initializerDefineProperty(this, "temperature", _descriptor3, this);
this.configStr = void 0;
this.toSingleMeta = function (name) {
if (!name) {
if (_this.models.length === 0) {
var _meta2 = _this.toMeta();
return _objectSpread(_objectSpread({}, _meta2), {}, {
model_name: []
});
}
return undefined;
}
if (!_this.models.includes(name)) {
return undefined;
}
var meta = _this.toMeta();
return _objectSpread(_objectSpread({}, meta), {}, {
model_name: [name]
});
};
this.toMeta = function () {
var meta = {
id: _this.id,
nickname: _this.nickname,
model_name: _this.model_name,
temperature: _this.temperature
};
return meta;
};
this.toSingleMetas = function () {
if (_this.models.length === 0) {
return [_this.toSingleMeta()];
}
return _this.models.map(_this.toSingleMeta);
};
this.id = _meta.id;
this.nickname = _meta.nickname;
this.model_name = _meta.model_name;
this.temperature = _meta.temperature;
}
LLMProvider = inject(LLMProviderOption)(LLMProvider, undefined, 0) || LLMProvider;
_createClass(LLMProvider, [{
key: "name",
get: function get() {
return this.nickname;
},
set: function set(v) {
this.nickname = v;
}
}, {
key: "models",
get: function get() {
return this.model_name;
},
set: function set(v) {
this.models = v;
}
}]);
return LLMProvider;
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "nickname", [_dec2], {
configurable: true,
enumerable: true,
writable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "model_name", [_dec3], {
configurable: true,
enumerable: true,
writable: true,
initializer: function initializer() {
return [];
}
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "temperature", [_dec4], {
configurable: true,
enumerable: true,
writable: true,
initializer: null
})), _class2)) || _class);
export var LLMModel = (_dec5 = transient(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec5(_class3 = (_class4 = /*#__PURE__*/function () {
function LLMModel(_meta3) {
var _this2 = this;
_classCallCheck(this, LLMModel);
this.id = void 0;
_initializerDefineProperty(this, "nickname", _descriptor4, this);
_initializerDefineProperty(this, "model_name", _descriptor5, this);
_initializerDefineProperty(this, "temperature", _descriptor6, this);
this.configStr = void 0;
this.updateMeta = function (meta) {
if (!meta) {
return;
}
if (_this2.id !== meta.id) {
_this2.id = meta.id;
}
if (_this2.nickname !== meta.nickname) {
_this2.nickname = meta.nickname;
}
if (_this2.temperature !== meta.temperature) {
_this2.temperature = meta.temperature;
}
if (_this2.model_name.join(',') !== meta.model_name.join(',')) {
_this2.model_name = meta.model_name;
}
};
this.toMeta = function () {
var meta = {
id: _this2.id,
nickname: _this2.nickname,
model_name: _this2.model_name,
temperature: _this2.temperature
};
return meta;
};
this.id = _meta3.id;
this.nickname = _meta3.nickname;
this.model_name = _meta3.model_name;
this.updateMeta(_meta3);
}
LLMModel = inject(LLMModelOption)(LLMModel, undefined, 0) || LLMModel;
_createClass(LLMModel, [{
key: "name",
get: function get() {
return this.nickname;
},
set: function set(v) {
this.nickname = v;
}
}, {
key: "models",
get: function get() {
return this.model_name;
},
set: function set(v) {
this.models = v;
}
}]);
return LLMModel;
}(), (_descriptor4 = _applyDecoratedDescriptor(_class4.prototype, "nickname", [_dec6], {
configurable: true,
enumerable: true,
writable: true,
initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class4.prototype, "model_name", [_dec7], {
configurable: true,
enumerable: true,
writable: true,
initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class4.prototype, "temperature", [_dec8], {
configurable: true,
enumerable: true,
writable: true,
initializer: null
})), _class4)) || _class3);