Skip to content

Simplify actions typing #11390

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 14 commits into from
Mar 16, 2025
2 changes: 1 addition & 1 deletion front/components/actions/SearchLabelsActionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CollapsibleComponent, MagnifyingGlassIcon } from "@dust-tt/sparkle";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { SearchLabelsActionType } from "@app/lib/actions/types/search_labels";
import type { SearchLabelsActionType } from "@app/lib/actions/search_labels";

export function SearchLabelsActionDetails({
action,
Expand Down
2 changes: 1 addition & 1 deletion front/components/actions/browse/BrowseActionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { BrowseActionType } from "@app/lib/actions/types/browse";
import type { BrowseActionType } from "@app/lib/actions/browse";

export function BrowseActionDetails({
action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MagnifyingGlassIcon } from "@dust-tt/sparkle";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { ConversationIncludeFileActionType } from "@app/lib/actions/types/conversation/include_file";
import type { ConversationIncludeFileActionType } from "@app/lib/actions/conversation/include_file";

export function ConversationIncludeFileActionDetails({
action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { capitalize } from "lodash";
import { useMemo } from "react";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import { getDustAppRunResultsFileTitle } from "@app/components/actions/dust_app_run/utils";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import { DUST_CONVERSATION_HISTORY_MAGIC_INPUT_KEY } from "@app/lib/actions/constants";
import type { DustAppRunActionType } from "@app/lib/actions/types/dust_app_run";
import { getDustAppRunResultsFileTitle } from "@app/lib/actions/types/dust_app_run";
import type { DustAppRunActionType } from "@app/lib/actions/dust_app_run";
import type { SupportedFileContentType } from "@app/types";

function ContentTypeIcon({
Expand Down
16 changes: 16 additions & 0 deletions front/components/actions/dust_app_run/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { SupportedFileContentType } from "@app/types";

export function getDustAppRunResultsFileTitle({
appName,
resultsFileContentType,
}: {
appName: string;
resultsFileContentType: SupportedFileContentType;
}): string {
const extension = resultsFileContentType.split("/").pop();
let title = `${appName}_output`;
if (extension) {
title += `.${extension}`;
}
return title;
}
4 changes: 2 additions & 2 deletions front/components/actions/process/ProcessActionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useMemo } from "react";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { ProcessActionType } from "@app/lib/actions/types/process";
import { PROCESS_ACTION_TOP_K } from "@app/lib/actions/types/process";
import { PROCESS_ACTION_TOP_K } from "@app/lib/actions/constants";
import type { ProcessActionType } from "@app/lib/actions/process";

export function ProcessActionDetails({
action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Markdown } from "@dust-tt/sparkle";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { ReasoningActionType } from "@app/lib/actions/types/reasoning";
import type { ReasoningActionType } from "@app/lib/actions/reasoning";

export function ReasoningActionDetails({
action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import { makeDocumentCitations } from "@app/components/actions/retrieval/utils";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { RetrievalActionType } from "@app/lib/actions/types/retrieval";
import type { RetrievalActionType } from "@app/lib/actions/retrieval";

export function RetrievalActionDetails({
action,
Expand Down
45 changes: 40 additions & 5 deletions front/components/actions/retrieval/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
import type { MarkdownCitation } from "@app/components/markdown/MarkdownCitation";
import { citationIconMap } from "@app/components/markdown/MarkdownCitation";
import type { RetrievalDocumentType } from "@app/lib/actions/types/retrieval";
import {
getProviderFromRetrievedDocument,
getTitleFromRetrievedDocument,
} from "@app/lib/actions/types/retrieval";
import type { RetrievalDocumentType } from "@app/lib/actions/retrieval";
import type { ConnectorProvider } from "@app/types";

type ConnectorProviderDocumentType =
| Exclude<ConnectorProvider, "webcrawler">
| "document";

export function getProviderFromRetrievedDocument(
document: RetrievalDocumentType
): ConnectorProviderDocumentType {
if (document.dataSourceView) {
if (document.dataSourceView.dataSource.connectorProvider === "webcrawler") {
return "document";
}
return document.dataSourceView.dataSource.connectorProvider || "document";
}
return "document";
}

export function getTitleFromRetrievedDocument(
document: RetrievalDocumentType
): string {
const provider = getProviderFromRetrievedDocument(document);

if (provider === "slack") {
for (const t of document.tags) {
if (t.startsWith("channelName:")) {
return `#${t.substring(12)}`;
}
}
}

for (const t of document.tags) {
if (t.startsWith("title:")) {
return t.substring(6);
}
}

return document.documentId;
}

export function makeDocumentCitation(
document: RetrievalDocumentType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
import { useCallback } from "react";

import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import { getTablesQueryResultsFileTitle } from "@app/components/actions/tables_query/utils";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import type { TablesQueryActionType } from "@app/lib/actions/types/tables_query";
import { getTablesQueryResultsFileTitle } from "@app/lib/actions/types/tables_query";
import type { TablesQueryActionType } from "@app/lib/actions/tables_query";
import type { LightWorkspaceType } from "@app/types";

export function TablesQueryActionDetails({
Expand Down
9 changes: 9 additions & 0 deletions front/components/actions/tables_query/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function getTablesQueryResultsFileTitle({
output,
}: {
output: Record<string, unknown> | null;
}): string {
return typeof output?.query_title === "string"
? output.query_title
: "query_results";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { ActionDetailsWrapper } from "@app/components/actions/ActionDetailsWrapper";
import type { ActionDetailsComponentBaseProps } from "@app/components/actions/types";
import { makeWebsearchResultsCitations } from "@app/components/actions/websearch/utils";
import type { WebsearchActionType } from "@app/lib/actions/types/websearch";
import type { WebsearchActionType } from "@app/lib/actions/websearch";

export function WebsearchActionDetails({
action,
Expand Down
2 changes: 1 addition & 1 deletion front/components/actions/websearch/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { MarkdownCitation } from "@app/components/markdown/MarkdownCitation
import type {
WebsearchActionType,
WebsearchResultType,
} from "@app/lib/actions/types/websearch";
} from "@app/lib/actions/websearch";

export function makeWebsearchResultsCitation(
result: WebsearchResultType
Expand Down
4 changes: 2 additions & 2 deletions front/components/assistant/conversation/AgentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ import {
visualizationDirective,
} from "@app/components/markdown/VisualizationBlock";
import { useEventSource } from "@app/hooks/useEventSource";
import type { RetrievalActionType } from "@app/lib/actions/retrieval";
import type { AgentActionSpecificEvent } from "@app/lib/actions/types/agent";
import {
isRetrievalActionType,
isWebsearchActionType,
} from "@app/lib/actions/types/guards";
import type { RetrievalActionType } from "@app/lib/actions/types/retrieval";
import type { WebsearchActionType } from "@app/lib/actions/types/websearch";
import type { WebsearchActionType } from "@app/lib/actions/websearch";
import { useSubmitFunction } from "@app/lib/client/utils";
import { useAgentConfigurationLastAuthor } from "@app/lib/swr/assistants";
import type {
Expand Down
12 changes: 6 additions & 6 deletions front/components/assistant/details/AssistantActionsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ import { useMemo, useState } from "react";
import DataSourceViewDocumentModal from "@app/components/DataSourceViewDocumentModal";
import { DataSourceViewPermissionTree } from "@app/components/DataSourceViewPermissionTree";
import { useTheme } from "@app/components/sparkle/ThemeContext";
import type { DustAppRunConfigurationType } from "@app/lib/actions/dust_app_run";
import type {
DataSourceConfiguration,
RetrievalConfigurationType,
} from "@app/lib/actions/retrieval";
import type { TablesQueryConfigurationType } from "@app/lib/actions/tables_query";
import type { AgentActionConfigurationType } from "@app/lib/actions/types/agent";
import type { DustAppRunConfigurationType } from "@app/lib/actions/types/dust_app_run";
import {
isBrowseConfiguration,
isDustAppRunConfiguration,
Expand All @@ -34,11 +39,6 @@ import {
isTablesQueryConfiguration,
isWebsearchConfiguration,
} from "@app/lib/actions/types/guards";
import type {
DataSourceConfiguration,
RetrievalConfigurationType,
} from "@app/lib/actions/types/retrieval";
import type { TablesQueryConfigurationType } from "@app/lib/actions/types/tables_query";
import { getContentNodeInternalIdFromTableId } from "@app/lib/api/content_nodes";
import { getConnectorProviderLogoWithFallback } from "@app/lib/connector_providers";
import { getVisualForDataSourceViewContentNode } from "@app/lib/content_nodes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type {
AssistantBuilderProcessConfiguration,
} from "@app/components/assistant_builder/types";
import { EmptyCallToAction } from "@app/components/EmptyCallToAction";
import type { ProcessSchemaPropertyType } from "@app/lib/actions/types/process";
import type { ProcessSchemaPropertyType } from "@app/lib/actions/process";
import { classNames } from "@app/lib/utils";
import type { Result, SpaceType, WorkspaceType } from "@app/types";
import { Err, Ok } from "@app/types";
Expand Down
10 changes: 5 additions & 5 deletions front/components/assistant_builder/server_side_props_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import {
getDefaultWebsearchActionConfiguration,
} from "@app/components/assistant_builder/types";
import { REASONING_MODEL_CONFIGS } from "@app/components/providers/types";
import type { DustAppRunConfigurationType } from "@app/lib/actions/dust_app_run";
import type { ProcessConfigurationType } from "@app/lib/actions/process";
import type { ReasoningConfigurationType } from "@app/lib/actions/reasoning";
import type { RetrievalConfigurationType } from "@app/lib/actions/retrieval";
import type { TablesQueryConfigurationType } from "@app/lib/actions/tables_query";
import type { AgentActionConfigurationType } from "@app/lib/actions/types/agent";
import type { DustAppRunConfigurationType } from "@app/lib/actions/types/dust_app_run";
import {
isBrowseConfiguration,
isDustAppRunConfiguration,
Expand All @@ -20,10 +24,6 @@ import {
isTablesQueryConfiguration,
isWebsearchConfiguration,
} from "@app/lib/actions/types/guards";
import type { ProcessConfigurationType } from "@app/lib/actions/types/process";
import type { ReasoningConfigurationType } from "@app/lib/actions/types/reasoning";
import type { RetrievalConfigurationType } from "@app/lib/actions/types/retrieval";
import type { TablesQueryConfigurationType } from "@app/lib/actions/types/tables_query";
import { getContentNodesForDataSourceView } from "@app/lib/api/data_source_view";
import type { Authenticator } from "@app/lib/auth";
import { AppResource } from "@app/lib/resources/app_resource";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
DEFAULT_WEBSEARCH_ACTION_DESCRIPTION,
DEFAULT_WEBSEARCH_ACTION_NAME,
} from "@app/lib/actions/constants";
import type { RetrievalTimeframe } from "@app/lib/actions/types/retrieval";
import type { RetrievalTimeframe } from "@app/lib/actions/retrieval";
import type {
AgentConfigurationType,
LightAgentConfigurationType,
Expand Down
2 changes: 1 addition & 1 deletion front/components/assistant_builder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
DEFAULT_TABLES_QUERY_ACTION_NAME,
DEFAULT_WEBSEARCH_ACTION_NAME,
} from "@app/lib/actions/constants";
import type { ProcessSchemaPropertyType } from "@app/lib/actions/types/process";
import type { ProcessSchemaPropertyType } from "@app/lib/actions/process";
import type { FetchAssistantTemplateResponse } from "@app/pages/api/templates/[tId]";
import type {
AgentConfigurationScope,
Expand Down
Loading
Loading