Skip to content
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

Refactor Assistant builder: use Vaults, use Context #6768

Merged

Conversation

Fraggle
Copy link
Contributor

@Fraggle Fraggle commented Aug 14, 2024

Description

This PR is about using Vaults (& DataSourceViews) in the assistant builder flow.

The main changes to make it work with DataSourceView:

  • AssistantBuilderDataSourceModal store configurations mapping by dataSourceView.sId instead of dataSource.sId
  • Use LightContentNode (returned by Vault's api) instead of ContentNode (old api).
  • Use DataSourceViewType everywhere in builder and in the configurations.
  • Use useVaultDataSourceViewContent instead of useConnectorPermissions.
  • Refactored global assistants to use datasourceview

Note: it will break using "@dust" locally.

Risk

Break assistant builder

Deploy Plan

Deploy front-edge, test, deploy front

@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch from fb3d3f0 to 88abec2 Compare August 16, 2024 16:50
@Fraggle Fraggle requested a review from flvndvd August 19, 2024 08:33
@Fraggle Fraggle marked this pull request as ready for review August 19, 2024 10:15
@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch from 48fa4be to 3c3285a Compare August 19, 2024 10:16
front/components/DataSourceResourceSelectorTree.tsx Outdated Show resolved Hide resolved
front/components/DataSourceResourceSelectorTree.tsx Outdated Show resolved Hide resolved
front/components/DataSourceResourceSelectorTree.tsx Outdated Show resolved Hide resolved
front/hooks/useParentResourcesById.ts Outdated Show resolved Hide resolved
front/lib/resources/data_source_resource.ts Show resolved Hide resolved
front/lib/resources/vault_resource.ts Outdated Show resolved Hide resolved
front/lib/resources/vault_resource.ts Outdated Show resolved Hide resolved
@Fraggle
Copy link
Contributor Author

Fraggle commented Aug 19, 2024

@flvndvd feedback adressed, feel free to re-review.

@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch from 15eaf10 to c6a9600 Compare August 19, 2024 14:33
front/components/DataSourceResourceSelectorTree.tsx Outdated Show resolved Hide resolved
front/lib/swr.ts Outdated Show resolved Hide resolved
front/components/DataSourceResourceSelectorTree.tsx Outdated Show resolved Hide resolved
@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch 5 times, most recently from 7d4149c to 88f9ca6 Compare August 22, 2024 10:25
front/components/ConnectorPermissionsTree.tsx Outdated Show resolved Hide resolved
@@ -357,7 +357,7 @@ function DataSourcesSection({
<div className="flex flex-col gap-1">
<ManagedDataSourceDocumentModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self, move to DataSourceViewDocumentModal once this PR is merged.

front/components/assistant_builder/AssistantBuilder.tsx Outdated Show resolved Hide resolved
front/lib/swr.ts Outdated Show resolved Hide resolved
front/lib/swr.ts Outdated Show resolved Hide resolved
front/pages/w/[wId]/builder/data-sources/public-urls.tsx Outdated Show resolved Hide resolved
front/scripts/helpers.ts Show resolved Hide resolved
@@ -62,7 +62,7 @@ const RetrievalActionConfigurationSchema = t.type({
dataSources: t.array(
t.type({
dataSourceId: t.string,
dataSourceViewId: t.union([t.string, t.null]),
dataSourceViewId: t.string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break the assistant builder for users already on the builder when we release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you propose ?

@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch 5 times, most recently from 581a3d1 to cecd6d8 Compare August 23, 2024 08:50
@Fraggle Fraggle force-pushed the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch from cecd6d8 to ba1c0ff Compare August 23, 2024 12:14
Copy link
Contributor

@flvndvd flvndvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few minor comments, but they aren't critical. Let's go ahead and merge this PR since it is holding up several others. We can address those comments in a subsequent PR.

@@ -446,7 +444,7 @@ function DataSourceSelectedNodes({

return (
<>
{dataSourceSelectedNodes.nodes.map((node: ContentNode) => (
{dataSourceSelectedNodes.nodes.map((node: LightContentNode) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we have not yet changed useDataSourceContentNodes this should still be a ContentNode

@@ -322,7 +322,7 @@ export default function AssistantBuilder({
});
} else {
await mutate(
`/api/w/${owner.sId}/data_sources/${slackDataSource?.name}/managed/slack/channels_linked_with_agent`
`/api/w/${owner.sId}/data_sources/${slackDataSource?.dataSource.name}/managed/slack/channels_linked_with_agent`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but slackDataSource should be named slackDataSourceView here.

import { CONNECTOR_CONFIGURATIONS } from "@app/lib/connector_providers";
import { AssistantBuilderContext } from "@app/components/assistant_builder/AssistantBuilderContext";
import { orderDatasourceViewByImportance } from "@app/lib/assistant";
import { getConnectorProviderLogoWithFallback } from "@app/lib/connector_providers";
import { getDisplayNameForDataSource } from "@app/lib/data_sources";

export default function PickDataSource({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up item, renamed this component to PickDataSourceView.

@@ -143,7 +143,9 @@ export function EditVaultManagedDataSourcesViews({
}}
owner={owner}
systemVaultDataSourceViews={systemVaultDataSourceViews.filter(
(ds) => ds.connectorProvider && ds.connectorProvider !== "webcrawler"
(dsv) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up item we can use isManaged here.

Comment on lines +95 to +99
const defaultVaults = [await VaultResource.fetchWorkspaceGlobalVault(auth)];
const dataSourceViews = await DataSourceViewResource.listByVaults(
auth,
defaultVaults
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
const defaultVaults = [await VaultResource.fetchWorkspaceGlobalVault(auth)];
const dataSourceViews = await DataSourceViewResource.listByVaults(
auth,
defaultVaults
);
const globalVault = await VaultResource.fetchWorkspaceGlobalVault(auth);
const dataSourceViews = await DataSourceViewResource.listByVaults(
auth,
[globalVault]
);

// Used when returning an agent with status 'disabled_by_admin'
const dummyModelConfiguration = {
providerId: GPT_4O_MODEL_CONFIG.providerId,
modelId: GPT_4O_MODEL_CONFIG.modelId,
temperature: 0,
};

type PrefetchedDataSourcesType = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up item, rename.

@@ -13,6 +13,8 @@ import type {
DataSourceViewType,
WhitelistableFeature,
} from "@dust-tt/types";
import type { LucideIcon } from "lucide-react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait we should not use any of those icons 🤔

}
await makePatchRequest(
transcriptConfigurationId,
{
dataSourceId: dataSource ? dataSource.name : null,
dataSourceId: dataSource ? dataSource.dataSource.name : null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up item rename to dataSourceView.

@Fraggle Fraggle merged commit 26baf3f into main Aug 23, 2024
3 checks passed
@Fraggle Fraggle deleted the 1149-groups-ui-update-assistant-builder-ui-to-use-vaults branch August 23, 2024 12:59
albandum pushed a commit that referenced this pull request Aug 28, 2024
* Refactor Assistant builder: use Vaults, use Context

* Fix: wrong key for actions initial configurations

* Fix: force close when picking a table from a folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants