Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

1.8 KB
Raw Blame
import { useEffect } from 'react';
import { Badge } from '@signozhq/ui/badge';
import { Tabs } from 'antd';
import logEvent from 'api/common/logEvent';
import { useListUnmappedLLMModels } from 'api/generated/services/llmpricingrules';
import { parseAsStringEnum, useQueryState } from 'nuqs';

import { MODEL_COSTS_TAB, TAB_KEY, UNPRICED_MODELS_TAB } from './constants';
import styles from './LLMObservabilityModelPricing.module.scss';
import ModelCostTabPanel from './ModelCostTabPanel';
import UnpricedModelsTab from './UnpricedModelsTab';

function LLMObservabilityModelPricing(): JSX.Element {
	const [activeTab, setActiveTab] = useQueryState(
		TAB_KEY,
		parseAsStringEnum([MODEL_COSTS_TAB, UNPRICED_MODELS_TAB]).withDefault(
			MODEL_COSTS_TAB,
		),
	);

	// Count powers the tab badge; deduped with the tab's own fetch by react-query.
	const { data } = useListUnmappedLLMModels();
	const unpricedCount = data?.data?.items?.length ?? 0;

	useEffect(() => {
		void logEvent('AI Observability Model Pricing: Page visited', {});
	}, []);

	return (
		<div
			className={styles.llmObservabilityModelPricing}
			data-testid="llm-observability-model-pricing-page"
		>
			<Tabs
				activeKey={activeTab}
				onChange={(key): void => {
					void setActiveTab(key as typeof activeTab);
				}}
				items={[
					{
						key: MODEL_COSTS_TAB,
						label: 'Model Costs',
						children: <ModelCostTabPanel />,
					},
					{
						key: UNPRICED_MODELS_TAB,
						label: (
							<span className={styles.tabLabel}>
								Unpriced models
								{unpricedCount > 0 && (
									<Badge color="primary" variant="solid" testId="unpriced-models-count">
										{unpricedCount}
									</Badge>
								)}
							</span>
						),
						children: <UnpricedModelsTab />,
					},
				]}
			/>
		</div>
	);
}

export default LLMObservabilityModelPricing;