UI: Fix settings precedence, Factory < Admin (--ui-config-file) < Users (Settings panel) (#26002)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ParameterSyncService } from './parameter-sync.service';
|
||||
import { ColorMode } from '$lib/enums';
|
||||
|
||||
describe('ParameterSyncService', () => {
|
||||
describe('roundFloatingPoint', () => {
|
||||
@@ -132,18 +131,13 @@ describe('ParameterSyncService', () => {
|
||||
expect(result.temperature).toBe(0.7);
|
||||
});
|
||||
|
||||
it('should merge ui settings from props when provided', () => {
|
||||
const result = ParameterSyncService.extractServerDefaults(null, {
|
||||
pasteLongTextToFileLen: 0,
|
||||
pdfAsImage: true,
|
||||
renderUserContentAsMarkdown: false,
|
||||
theme: ColorMode.DARK
|
||||
});
|
||||
it('extracts sampling twins only, never ui settings', () => {
|
||||
const result = ParameterSyncService.extractServerDefaults(null);
|
||||
|
||||
expect(result.pasteLongTextToFileLen).toBe(0);
|
||||
expect(result.pdfAsImage).toBe(true);
|
||||
expect(result.renderUserContentAsMarkdown).toBe(false);
|
||||
expect(result.theme).toBeUndefined();
|
||||
expect(result).toEqual({});
|
||||
expect(ParameterSyncService.canSyncParameter('theme')).toBe(false);
|
||||
expect(ParameterSyncService.canSyncParameter('pdfAsImage')).toBe(false);
|
||||
expect(ParameterSyncService.canSyncParameter('temperature')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,12 +29,10 @@ export class ParameterSyncService {
|
||||
* Converts samplers array to semicolon-delimited string for UI display.
|
||||
*
|
||||
* @param serverParams - Raw generation settings from server `/props` endpoint
|
||||
* @param uiSettings - Optional UI-specific settings from server
|
||||
* @returns Record of extracted parameter key-value pairs with normalized precision
|
||||
*/
|
||||
static extractServerDefaults(
|
||||
serverParams: ApiLlamaCppServerProps['default_generation_settings']['params'] | null,
|
||||
uiSettings?: Record<string, string | number | boolean>
|
||||
serverParams: ApiLlamaCppServerProps['default_generation_settings']['params'] | null
|
||||
): ParameterRecord {
|
||||
const extracted: ParameterRecord = {};
|
||||
|
||||
@@ -57,18 +55,6 @@ export class ParameterSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
if (uiSettings) {
|
||||
for (const param of SYNCABLE_PARAMETERS) {
|
||||
if (param.canSync && param.serverKey in uiSettings) {
|
||||
const value = uiSettings[param.serverKey];
|
||||
|
||||
if (value !== undefined) {
|
||||
extracted[param.key] = this.roundFloatingPoint(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return extracted;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user