InfoRadar / client /src /ts /utils /visualizationConfigs.ts
dqy08's picture
多语言国际化支持
5b3181a
import { tr } from '../lang/i18n-lite';
/**
* 直方图基础配置类型
*/
export interface HistogramBaseConfig {
label: string;
no_bins: number;
extent: [number, number];
averageLabel: string;
showLeftInfinity?: boolean;
xAxisTickSkip?: number;
}
/**
* 散点图基础配置类型
*/
export interface ScatterPlotBaseConfig {
xLabel: string;
yLabel: string;
label?: string;
}
/**
* 获取 Token information 直方图配置(支持国际化)
*/
export const getTokenSurprisalHistogramConfig = (): HistogramBaseConfig => ({
label: tr("information per token histogram"),
no_bins: 19,
extent: [0, 19],
averageLabel: tr("bits/token"),
});
/**
* 获取 Byte information 直方图配置(支持国际化)
*/
export const getByteSurprisalHistogramConfig = (): HistogramBaseConfig => ({
label: tr("information per byte histogram"),
no_bins: 13,
extent: [0, 6.5],
averageLabel: tr("bits/Byte"),
});
/**
* 获取 ΔByte information 直方图配置(支持国际化)
*/
export const getDeltaByteSurprisalHistogramConfig = (): HistogramBaseConfig => ({
label: tr("Δinformation per byte histogram"),
no_bins: 20,
xAxisTickSkip: 1, // x轴刻度数字绘制间隔
extent: [-5, 5],
averageLabel: tr("Δ bits/Byte"),
showLeftInfinity: true, // 左侧显示 -∞ 符号
});
/**
* 获取 Information progress 散点图配置(支持国际化)
*/
export const getSurprisalProgressConfig = (): ScatterPlotBaseConfig => ({
label: tr("information per token progress"),
xLabel: tr("token index"),
yLabel: tr("information (bits)"),
});