UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
108 lines (104 loc) 3.17 kB
'use strict'; var numeric_constant = require('../constant/numeric.constant.js'); var commitMode_enum = require('../enum/commit-mode.enum.js'); /** * Entity representing LLM configuration */ class LLMConfiguration { API_KEY; MAX_RETRIES; MODE; MODEL; PROVIDER; VALIDATION_MAX_RETRIES; constructor(provider, apiKey, mode, model, maxRetries = numeric_constant.DEFAULT_MAX_RETRIES, validationMaxRetries = numeric_constant.DEFAULT_VALIDATION_MAX_RETRIES) { this.PROVIDER = provider; this.API_KEY = apiKey; this.MODE = mode; this.MODEL = model; this.MAX_RETRIES = maxRetries; this.VALIDATION_MAX_RETRIES = validationMaxRetries; } /** * Get the API key * @returns {ApiKey} The API key */ getApiKey() { return this.API_KEY; } /** * Get the maximum retries * @returns {number} The maximum retries */ getMaxRetries() { return this.MAX_RETRIES; } /** * Get the commit mode * @returns {ECommitMode} The commit mode */ getMode() { return this.MODE; } /** * Get the model name * @returns {string | undefined} The model name or undefined */ getModel() { return this.MODEL; } /** * Get the LLM provider * @returns {ELLMProvider} The LLM provider */ getProvider() { return this.PROVIDER; } /** * Get the validation max retries * @returns {number} The validation max retries */ getValidationMaxRetries() { return this.VALIDATION_MAX_RETRIES; } /** * Check if mode is auto * @returns {boolean} True if mode is auto */ isAutoMode() { return this.MODE === commitMode_enum.ECommitMode.AUTO; } /** * Check if mode is manual * @returns {boolean} True if mode is manual */ isManualMode() { return this.MODE === commitMode_enum.ECommitMode.MANUAL; } /** * Create a new configuration with a different API key * @param {ApiKey} apiKey - The new API key * @returns {LLMConfiguration} A new configuration with the updated API key */ withApiKey(apiKey) { return new LLMConfiguration(this.PROVIDER, apiKey, this.MODE, this.MODEL, this.MAX_RETRIES, this.VALIDATION_MAX_RETRIES); } /** * Create a new configuration with a different mode * @param {ECommitMode} mode - The new mode * @returns {LLMConfiguration} A new configuration with the updated mode */ withMode(mode) { return new LLMConfiguration(this.PROVIDER, this.API_KEY, mode, this.MODEL, this.MAX_RETRIES, this.VALIDATION_MAX_RETRIES); } /** * Create a new configuration with updated model * @param {string} model - The new model name * @returns {LLMConfiguration} A new configuration with the updated model */ withModel(model) { return new LLMConfiguration(this.PROVIDER, this.API_KEY, this.MODE, model, this.MAX_RETRIES, this.VALIDATION_MAX_RETRIES); } } exports.LLMConfiguration = LLMConfiguration; //# sourceMappingURL=llm-configuration.entity.js.map