ravendb
Version:
RavenDB client for Node.js
55 lines • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HuggingFaceSettings = void 0;
const AbstractAiSettings_js_1 = require("./AbstractAiSettings.js");
const AiSettingsCompareDifferences_js_1 = require("../AiSettingsCompareDifferences.js");
const StringUtil_js_1 = require("../../../../../Utility/StringUtil.js");
/**
* Settings for HuggingFace service.
*/
class HuggingFaceSettings extends AbstractAiSettings_js_1.AbstractAiSettings {
/**
* The name of the Hugging Face model.
*/
model;
/**
* The endpoint for the text embedding generation service. If not specified, the default endpoint will be used.
*/
endpoint;
/**
* The API key required for accessing the Hugging Face service.
*/
apiKey;
constructor(apiKey, model, endpoint) {
super();
this.model = model;
this.endpoint = endpoint;
this.apiKey = apiKey;
}
validate(errors) {
if (StringUtil_js_1.StringUtil.isNullOrWhitespace(this.model)) {
errors.push("Value of 'model' field cannot be empty.");
}
if (StringUtil_js_1.StringUtil.isNullOrWhitespace(this.apiKey)) {
errors.push("Value of 'apiKey' field cannot be empty.");
}
}
compare(other) {
if (!(other instanceof HuggingFaceSettings)) {
return AiSettingsCompareDifferences_js_1.AiSettingsCompareDifferences.All;
}
let differences = AiSettingsCompareDifferences_js_1.AiSettingsCompareDifferences.None;
if (this.model !== other.model) {
differences |= AiSettingsCompareDifferences_js_1.AiSettingsCompareDifferences.ModelArchitecture;
}
if (this.endpoint !== other.endpoint) {
differences |= AiSettingsCompareDifferences_js_1.AiSettingsCompareDifferences.EndpointConfiguration;
}
if (this.apiKey !== other.apiKey) {
differences |= AiSettingsCompareDifferences_js_1.AiSettingsCompareDifferences.AuthenticationSettings;
}
return differences;
}
}
exports.HuggingFaceSettings = HuggingFaceSettings;
//# sourceMappingURL=HuggingFaceSettings.js.map