Skip to content

Commit 5f9444d

Browse files
authored
add think tool (#254)
1 parent d4f4cc9 commit 5f9444d

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

apps/src/metabase/appController.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,24 @@ export class MetabaseController extends AppController<MetabaseAppState> {
842842
return actionContent;
843843
}
844844

845+
@Action({
846+
labelRunning: "Thinking",
847+
labelDone: "Formulated a plan",
848+
labelTask: "Formulated a plan",
849+
description: "Formulates a plan to answer the user's request.",
850+
renderBody: ({ thoughts }: { thoughts: string }) => {
851+
return { text: null, code: null }
852+
}
853+
})
854+
async Think({ thoughts }: { thoughts: string[] }) {
855+
const actionContent: DefaultMessageContent = {
856+
type: "DEFAULT",
857+
text: `Thinking:\n${thoughts}`,
858+
images: [],
859+
};
860+
return actionContent;
861+
}
862+
845863
// 1. Internal actions -------------------------------------------
846864
async checkVisualizationInvalid() {
847865
let returnMessage = "Visualization set successfully";

web/src/components/common/TaskUI.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,22 @@ const TaskUI = forwardRef<HTMLTextAreaElement>((_props, ref) => {
233233
toastDescription = "Please select a database"
234234
preventRunTask = true
235235
}
236-
else if (toolContext.pageType === 'dashboard' && !drMode) {
236+
else if (toolContext.pageType === 'dashboard' && (!drMode || analystMode)) {
237237
toastTitle = 'Dashboard is supported only in agent mode'
238238
toastDescription = "You can enable agent mode in settings"
239239
preventRunTask = true
240240
}
241-
else if (toolContext.pageType === 'mbql' && !drMode) {
241+
else if (toolContext.pageType === 'mbql' && (!drMode || analystMode)) {
242242
toastTitle = 'MBQL Editor is supported only in agent mode'
243243
toastDescription = "You can enable agent mode in settings"
244244
preventRunTask = true
245245
}
246-
else if (toolContext.pageType === 'mbql' && selectedCatalog != DEFAULT_TABLES) {
246+
else if (toolContext.pageType === 'mbql' && (selectedCatalog != DEFAULT_TABLES || analystMode)) {
247247
toastTitle = 'MBQL Editor is supported only in Default Tables catalog'
248248
toastDescription = "You can switch to Default Tables catalog in settings"
249249
preventRunTask = true
250250
}
251-
else if (selectedCatalog === DEFAULT_TABLES && isEmpty(validAddedTables) && isEmpty(validSelectedModels)) {
251+
else if (selectedCatalog === DEFAULT_TABLES && isEmpty(validAddedTables) && isEmpty(validSelectedModels) && !analystMode) {
252252
toastTitle = 'No Table in Default Tables'
253253
toastDescription = "Please select at least one table in Default Tables catalog"
254254
preventRunTask = true
@@ -380,6 +380,9 @@ const TaskUI = forwardRef<HTMLTextAreaElement>((_props, ref) => {
380380
{
381381
isAppEnabled && !shouldBeEnabled && <DisabledOverlay toolEnabledReason={"You're currently using MinusX Classic, which only works on SQL Editor pages. [Find out](https://minusx.ai/demo) how to enable Agent mode and unlock all the features!"}/>
382382
}
383+
{
384+
analystMode && (toolContext.pageType != 'sql') && <DisabledOverlay toolEnabledReason={"You're currently using `[badge]Analyst Mode (alpha)`, which only works on SQL Editor pages for now!"}/>
385+
}
383386
<VStack
384387
justifyContent="space-between"
385388
alignItems="stretch"

0 commit comments

Comments
 (0)