🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
import type { GatewayIngestionMode } from "@langfuse/shared";
import { env } from "@/src/env.mjs";
const STORED_INGESTION_MODES = [
"NONE",
"USAGE",
"FULL",
] as const satisfies readonly GatewayIngestionMode[];
/** Langfuse Cloud records a generation for every gateway request, so `NONE` is self-hosted only. */
export function isGatewayIngestionModeAvailable(mode: GatewayIngestionMode) {
return mode !== "NONE" || !env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
}
/**
* The mode a stored config runs with. A `NONE` config stored on Cloud
* captures usage, the minimal level, so no request goes unrecorded.
*/
export function getEffectiveGatewayIngestionMode(
mode: GatewayIngestionMode,
): GatewayIngestionMode {
return isGatewayIngestionModeAvailable(mode) ? mode : "USAGE";
}
/** Stored modes under which the gateway writes into the ingestion project. */
export function getCapturingGatewayIngestionModes() {
return STORED_INGESTION_MODES.filter(
(mode) => getEffectiveGatewayIngestionMode(mode) !== "NONE",
);
}