-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add Metabase AI Tools #17673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Metabase AI Tools #17673
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
799423b
Add shortcuts to focus inputs
vimtor 69d6ba4
Add @vimtor as a contributor of the Things 3 extension
vimtor dcfaaee
Update add-new-project.tsx
pernielsentikaer 32dc85b
Update add-new-todo.tsx
pernielsentikaer d2ab366
Merge branch 'raycast:main' into main
vimtor 1ffa5f0
Merge branch 'raycast:main' into main
vimtor 7744015
Merge branch 'raycast:main' into main
vimtor fca8c4a
Merge branch 'raycast:main' into main
vimtor 81ee57a
Merge branch 'raycast:main' into main
vimtor 3465023
Initial version
vimtor 5d2a793
AI tools for Metabase extension
vimtor 268a671
Add `requiresConfirmation` option to run question AI tool
vimtor 47897b2
Add AI evals to `package.json`
vimtor d00a994
Fix weird linting errors
vimtor ccc1a92
Fix ESLint
vimtor f36790f
Update CHANGELOG.md and optimise images
raycastbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Metabase Changelog | ||
|
||
## [AI Tools] - 2025-07-07 | ||
|
||
## [Initial Version] - 2025-02-01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { defineConfig } = require("eslint/config"); | ||
const raycastConfig = require("@raycast/eslint-config"); | ||
|
||
module.exports = defineConfig([...raycastConfig]); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,136 @@ | ||||||||||||||
import { getPreferenceValues } from "@raycast/api"; | ||||||||||||||
|
||||||||||||||
const preferences = getPreferenceValues<Preferences.SearchQuestions>(); | ||||||||||||||
|
||||||||||||||
export interface Database { | ||||||||||||||
id: number; | ||||||||||||||
name: string; | ||||||||||||||
engine: string; | ||||||||||||||
tables: { | ||||||||||||||
name: string; | ||||||||||||||
schema: string; | ||||||||||||||
// and other fields | ||||||||||||||
}[]; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export interface Card { | ||||||||||||||
id: number; | ||||||||||||||
name: string; | ||||||||||||||
description: string | null; | ||||||||||||||
created_at: string; | ||||||||||||||
updated_at: string; | ||||||||||||||
archived: boolean; | ||||||||||||||
view_count: number; | ||||||||||||||
display: "bar" | "table" | "scalar" | "line" | "pie" | (string & Record<string, never>); | ||||||||||||||
dataset_query: { | ||||||||||||||
database: number; | ||||||||||||||
native: { | ||||||||||||||
query: string; | ||||||||||||||
template_tags: Record<string, { display_name: string; id: string; name: string; type: string }>; | ||||||||||||||
}; | ||||||||||||||
type: "native"; | ||||||||||||||
}; | ||||||||||||||
creator: { | ||||||||||||||
email: string; | ||||||||||||||
first_name: string; | ||||||||||||||
last_login: string; | ||||||||||||||
is_qbnewb: boolean; | ||||||||||||||
is_superuser: boolean; | ||||||||||||||
id: number; | ||||||||||||||
last_name: string; | ||||||||||||||
date_joined: string; | ||||||||||||||
common_name: string; | ||||||||||||||
}; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export interface Query { | ||||||||||||||
rows: string[][]; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function runQuery(input: { query: string; databaseId: number }) { | ||||||||||||||
const endpoint = new URL(`/api/dataset`, preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "POST", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
"content-type": "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
}, | ||||||||||||||
body: JSON.stringify({ | ||||||||||||||
database: input.databaseId, | ||||||||||||||
type: "native", | ||||||||||||||
native: { | ||||||||||||||
query: input.query, | ||||||||||||||
}, | ||||||||||||||
}), | ||||||||||||||
}) | ||||||||||||||
.then((res) => res.json() as Promise<{ data: Query }>) | ||||||||||||||
.then((res) => res.data); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function getQuestion(input: { questionId: number }) { | ||||||||||||||
const endpoint = new URL(`/api/card/${input.questionId}`, preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "GET", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
}, | ||||||||||||||
}).then((res) => res.json() as Promise<Card>); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function runQuestion(input: { questionId: number }) { | ||||||||||||||
const endpoint = new URL(`/api/card/${input.questionId}/query`, preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "POST", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
contentType: "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
Comment on lines
+90
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Header name should be 'content-type' (hyphenated) instead of 'contentType' to match other requests and HTTP standards
Suggested change
|
||||||||||||||
}, | ||||||||||||||
body: JSON.stringify({}), | ||||||||||||||
}).then((res) => res.json() as Promise<{ data: Query }>); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function getDatabases() { | ||||||||||||||
const endpoint = new URL("/api/database", preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
endpoint.searchParams.set("include", "tables"); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "GET", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
}, | ||||||||||||||
}) | ||||||||||||||
.then((res) => res.json() as Promise<{ data: Database[] }>) | ||||||||||||||
.then((res) => res.data); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function getDatabase(databaseId: number) { | ||||||||||||||
const endpoint = new URL(`/api/database/${databaseId}`, preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "GET", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
}, | ||||||||||||||
}).then((res) => res.json() as Promise<Database>); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function getQuestions() { | ||||||||||||||
const endpoint = new URL("/api/card", preferences.instanceUrl); | ||||||||||||||
|
||||||||||||||
return fetch(endpoint.toString(), { | ||||||||||||||
method: "GET", | ||||||||||||||
headers: { | ||||||||||||||
accept: "application/json", | ||||||||||||||
"x-api-key": preferences.apiToken, | ||||||||||||||
}, | ||||||||||||||
}).then((res) => res.json() as Promise<Card[]>); | ||||||||||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: No error handling for failed requests. Should check res.ok before parsing JSON and handle network errors in the catch block. Consider using showFailureToast from @raycast/utils for error handling.