Skip to content

Commit c239329

Browse files
authored
Merge pull request #29 from tinybirdco/fix-token
Fix token
2 parents 919686f + 0cd3292 commit c239329

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

dashboard/ai-analytics/src/lib/dimensions.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,7 @@ export const fetchAvailableDimensions = async () => {
88
}
99

1010
try {
11-
// SQL query to get all unique values for each dimension
12-
const query = `
13-
SELECT
14-
groupUniqArray(organization) as organization,
15-
groupUniqArray(project) as project,
16-
groupUniqArray(environment) as environment,
17-
groupUniqArray(model) as model,
18-
groupUniqArray(provider) as provider
19-
FROM llm_events WHERE timestamp > now() - interval '1 month' FORMAT JSON
20-
`;
21-
22-
// URL encode the query
23-
const encodedQuery = encodeURIComponent(query);
24-
const url = `${TINYBIRD_API_URL}/v0/sql?q=${encodedQuery}`;
25-
26-
console.log('Fetching available dimensions from:', url);
27-
11+
const url = `${TINYBIRD_API_URL}/v0/pipes/llm_dimensions.json`;
2812
const response = await fetch(url, {
2913
headers: {
3014
Authorization: `Bearer ${TINYBIRD_API_KEY}`,

dashboard/ai-analytics/src/middleware.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export default clerkMiddleware(async (auth) => {
4848
type: "PIPES:READ",
4949
resource: "llm_usage",
5050
fixed_params: { organization: orgName }
51+
},
52+
{
53+
type: "PIPES:READ",
54+
resource: "llm_dimensions",
55+
fixed_params: { organization: orgName }
5156
}
5257
],
5358
limits: {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
TOKEN read_pipes READ
2+
3+
NODE llm_dimensions_node
4+
SQL >
5+
%
6+
SELECT
7+
groupUniqArray(organization) as organizations,
8+
groupUniqArray(project) as project,
9+
groupUniqArray(environment) as environment,
10+
groupUniqArray(model) as model,
11+
groupUniqArray(provider) as provider
12+
FROM
13+
(
14+
SELECT organization, project, environment, model, provider
15+
FROM
16+
llm_events WHERE timestamp > now() - interval '1 month'
17+
{% if defined(organization) and organization != '' %}
18+
AND organization = {{String(organization, '')}}
19+
{% end %}
20+
)
21+
22+
23+
TYPE endpoint

0 commit comments

Comments
 (0)