mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-07-10 08:13:46 +00:00
fix(langfuse): type fanout collector config
This commit is contained in:
parent
25279f1d48
commit
59b9c8b242
3 changed files with 11 additions and 5 deletions
|
|
@ -1194,7 +1194,7 @@ describe('Langfuse run config', () => {
|
|||
collectorUrl: 'http://langfuse-fanout-collector:4318',
|
||||
},
|
||||
},
|
||||
} as AppConfig,
|
||||
} as unknown as AppConfig,
|
||||
});
|
||||
|
||||
expect(callArgs.langfuse).toEqual({
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ import { normalizeString } from '~/utils/text';
|
|||
import { isTrueEnv } from './utils';
|
||||
|
||||
type LangfuseRunConfig = NonNullable<RunConfig['langfuse']>;
|
||||
type LangfuseAppConfig = NonNullable<AppConfig['langfuse']>;
|
||||
export type LangfuseFanoutConfig = LangfuseAppConfig['fanout'] & {
|
||||
collectorUrl?: string;
|
||||
};
|
||||
type LangfuseRunConfigWithTraceAttributes = LangfuseRunConfig & {
|
||||
librechatTraceAttributes?: Record<string, string | number | boolean | null | undefined>;
|
||||
};
|
||||
|
|
@ -16,7 +20,7 @@ export function isLangfuseTenantExportEnabled(): boolean {
|
|||
return !isTrueEnv(process.env.LANGFUSE_FANOUT_TENANT_EXPORT_DISABLED);
|
||||
}
|
||||
|
||||
export function isLangfuseFanoutEnabled(fanout?: AppConfig['langfuse']['fanout']): boolean {
|
||||
export function isLangfuseFanoutEnabled(fanout?: LangfuseFanoutConfig): boolean {
|
||||
return (
|
||||
fanout?.enabled !== false &&
|
||||
(fanout?.enabled === true || isTrueEnv(process.env.LANGFUSE_FANOUT_ENABLED))
|
||||
|
|
@ -89,7 +93,7 @@ export function buildLangfuseConfig({
|
|||
const publicKey = normalizeString(config?.publicKey);
|
||||
const secretKey = normalizeString(config?.secretKey);
|
||||
const hasTenantCredentials = Boolean(publicKey && secretKey);
|
||||
const fanout = config?.fanout;
|
||||
const fanout = config?.fanout as LangfuseFanoutConfig | undefined;
|
||||
const fanoutEnabled = isLangfuseFanoutEnabled(fanout);
|
||||
const fanoutCollectorUrl =
|
||||
normalizeString(fanout?.collectorUrl) ??
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { AppConfig } from '@librechat/data-schemas';
|
||||
import type { LangfuseFanoutConfig } from './config';
|
||||
import { isLangfuseFanoutEnabled, isLangfuseTenantExportEnabled } from './config';
|
||||
import { resolveLangfuseTenantDestination } from './tenantDestinations';
|
||||
import { isFalseEnv, toBasicAuthorization } from './utils';
|
||||
|
|
@ -69,11 +70,12 @@ function getTenantScoreDestination(appConfig?: AppConfig): LangfuseScoreDestinat
|
|||
if (config?.enabled === false) {
|
||||
return undefined;
|
||||
}
|
||||
if (!isLangfuseFanoutEnabled(config?.fanout)) {
|
||||
const fanout = config?.fanout as LangfuseFanoutConfig | undefined;
|
||||
if (!isLangfuseFanoutEnabled(fanout)) {
|
||||
return undefined;
|
||||
}
|
||||
const fanoutCollectorUrl =
|
||||
normalizeString(config?.fanout?.collectorUrl) ??
|
||||
normalizeString(fanout?.collectorUrl) ??
|
||||
normalizeString(process.env.LANGFUSE_FANOUT_COLLECTOR_URL);
|
||||
if (!fanoutCollectorUrl) {
|
||||
return undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue