Add SystemOne classification support and release version 4.0.0
This commit is contained in:
parent
76195f9a92
commit
9a5404cb62
16 changed files with 923 additions and 579 deletions
32
modules/classificationConfig.js
Normal file
32
modules/classificationConfig.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { DEFAULT_AI_PARAMS } from './defaultParams.js';
|
||||
export const CONFIG_DEFAULTS = {
|
||||
apiType: 'chat-completions', endpoint: 'http://127.0.0.1:5000', model: '',
|
||||
apiKey: '', openaiOrganization: '', openaiProject: '', customSystemPrompt: '',
|
||||
decisionThreshold: 0.5, inputCharacterLimit: 3686, aiParams: DEFAULT_AI_PARAMS,
|
||||
htmlToMarkdown: false, stripUrlParams: false, altTextImages: false,
|
||||
collapseWhitespace: false, tokenReduction: false, debugLogging: false
|
||||
};
|
||||
export function validateThreshold(value) {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1) {
|
||||
throw new Error('Match threshold must be between 0% and 100%.');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
export function validateSettings(data) {
|
||||
if (data.apiType !== undefined && !['chat-completions', 'systemone'].includes(data.apiType)) throw new Error('Unknown API type.');
|
||||
if (data.decisionThreshold !== undefined) validateThreshold(data.decisionThreshold);
|
||||
if (data.inputCharacterLimit !== undefined && (!Number.isSafeInteger(data.inputCharacterLimit) || data.inputCharacterLimit < 1)) {
|
||||
throw new Error('Input character limit must be a positive integer.');
|
||||
}
|
||||
if (data.aiRules !== undefined) {
|
||||
if (!Array.isArray(data.aiRules)) throw new Error('Rules must be an array.');
|
||||
for (const rule of data.aiRules) {
|
||||
if (rule.decisionThreshold !== undefined) validateThreshold(rule.decisionThreshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
export function migratedInputLimit(data) {
|
||||
if (data.inputCharacterLimit !== undefined) return data.inputCharacterLimit;
|
||||
const value = Math.floor(Number(data.aiParams?.max_tokens ?? 4096) * 0.9);
|
||||
return Number.isSafeInteger(value) && value > 0 ? value : 3686;
|
||||
}
|
||||
Loading…
Reference in a new issue