Skip to content

Commit ccacbb8

Browse files
committed
fix(webapp,llm-model-catalog): scope model sparklines to project and add 1h cache alias
Scope getModelUsageSparklines by project_id alongside environment_id so it matches the other project-scoped queries and lets ClickHouse use the organization/project/environment key prefix. Add input_cache_creation_1h to the cache-creation price aliases so a model that defines only the 1h key is not dropped to the input price (no current model is affected; the base/5m alias still resolves first).
1 parent 7338f66 commit ccacbb8

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

apps/webapp/app/presenters/v3/ModelRegistryPresenter.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ export class ModelRegistryPresenter extends BasePresenter {
724724
* readable ~24-52 bars regardless of the selected period. Zero-filled.
725725
*/
726726
async getModelUsageSparklines(
727+
projectId: string,
727728
environmentId: string,
728729
responseModels: string[],
729730
from: Date,
@@ -758,14 +759,16 @@ export class ModelRegistryPresenter extends BasePresenter {
758759
toUnixTimestamp(toStartOfInterval(start_time, INTERVAL ${intervalSeconds} SECOND)) AS bucket,
759760
${valueExpr} AS val
760761
FROM trigger_dev.llm_metrics_v1
761-
WHERE environment_id = {environmentId: String}
762+
WHERE project_id = {projectId: String}
763+
AND environment_id = {environmentId: String}
762764
AND response_model IN {responseModels: Array(String)}
763765
AND start_time >= {startTime: String}
764766
AND start_time <= {endTime: String}
765767
GROUP BY response_model, bucket
766768
ORDER BY response_model, bucket
767769
`,
768770
params: z.object({
771+
projectId: z.string(),
769772
environmentId: z.string(),
770773
responseModels: z.array(z.string()),
771774
startTime: z.string(),
@@ -775,6 +778,7 @@ export class ModelRegistryPresenter extends BasePresenter {
775778
});
776779

777780
const queryParams = {
781+
projectId,
778782
environmentId,
779783
responseModels,
780784
startTime: formatDateForCH(from),

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.models._index/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
151151
]);
152152

153153
const usageSparklines = await presenter.getModelUsageSparklines(
154+
project.id,
154155
environment.id,
155156
projectUsage.map((u) => u.responseModel),
156157
time.from,

internal-packages/llm-model-catalog/src/registry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export class ModelPricingRegistry {
179179
"cache_creation_input_tokens",
180180
"input_cache_creation",
181181
"input_cache_creation_5m",
182+
"input_cache_creation_1h",
182183
]) ?? inputPrice;
183184

184185
const totalInputTokens = usageDetails["input"] ?? usageDetails["input_tokens"] ?? 0;

0 commit comments

Comments
 (0)