pierrejeambrun commented on code in PR #74334: URL: https://github.com/apache/airflow/pull/74334#discussion_r4206876097
########## providers/common/ai/src/airflow/providers/common/ai/plugins/www/src/components/ModelPanel.tsx: ########## @@ -0,0 +1,137 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Badge, Box, Flex, HStack, Heading, SimpleGrid, Spinner, Text } from "@chakra-ui/react"; +import type { FC, ReactNode } from "react"; +import { LuInfo } from "react-icons/lu"; + +import { NoModelInfo } from "src/components/NoModelInfo"; +import { Tooltip } from "src/components/Tooltip"; +import { useModelInfo } from "src/hooks/useModelInfo"; + +interface ModelPanelProps { + dagId: string; + runId: string; + taskId: string; + mapIndex: number; +} + +// Pydantic-ai prices a response via genai-prices' per-token rate lookup (see +// durable/replay_usage.py::fill_replayed_cost), not from provider-reported billing -- +// a model or provider the lookup doesn't recognise is left unpriced rather than guessed. +const COST_TOOLTIP = + "Estimated in USD from a per-token price lookup (genai-prices), not provider-reported " + + "billing -- best-effort, and may be stale or unavailable for some models/providers."; + +// The XCom keeps full precision (see utils/logging.py's format_usage_for_xcom) so a very +// cheap run doesn't look free in the logs; round to cents here for a readable display. +function formatCost(cost: string | null): string { + return cost === null ? "—" : `$${Number(cost).toFixed(2)}`; Review Comment: Fixed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
