Skip to content

Commit

Permalink
Pass data source view id to core for process action
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Aug 9, 2024
1 parent 6d31af3 commit 50ebf63
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions front/lib/api/assistant/actions/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,32 @@ export class ProcessConfigurationServerRunner extends BaseActionConfigurationSer
DustProdActionRegistry["assistant-v2-process"].config
);

// Transform each data source in actionConfiguration.dataSources by adding a
// `dataSourceOrViewId` field. This field will hold the value of `dataSourceViewId`
// if it exists; otherwise, it will fall back to `dataSourceId`
const actionConfigurationDataSources = actionConfiguration.dataSources.map(
(d) => {
const { dataSourceViewId, dataSourceId, ...rest } = d;
return {
...rest,
// We use dataSourceViewId if it exists, otherwise dataSourceId.
dataSourceOrViewId: dataSourceViewId ?? dataSourceId,
};
}
);

// Set the process action model configuration to the assistant model configuration.
config.MODEL.provider_id = model.providerId;
config.MODEL.model_id = model.modelId;
config.MODEL.temperature = model.temperature;

// Handle data sources list and parents/tags filtering.
config.DATASOURCE.data_sources = actionConfiguration.dataSources.map(
config.DATASOURCE.data_sources = actionConfigurationDataSources.map(
(d) => ({
workspace_id: isDevelopment()
? PRODUCTION_DUST_WORKSPACE_ID
: d.workspaceId,
data_source_id: d.dataSourceId,
data_source_id: d.dataSourceOrViewId,
})
);

Expand All @@ -275,15 +289,15 @@ export class ProcessConfigurationServerRunner extends BaseActionConfigurationSer
config.DATASOURCE.filter.tags.in = actionConfiguration.tagsFilter.in;
}

for (const ds of actionConfiguration.dataSources) {
for (const ds of actionConfigurationDataSources) {
if (!config.DATASOURCE.filter.parents) {
config.DATASOURCE.filter.parents = {};
}
if (ds.filter.parents?.in) {
if (!config.DATASOURCE.filter.parents.in_map) {
config.DATASOURCE.filter.parents.in_map = {};
}
config.DATASOURCE.filter.parents.in_map[ds.dataSourceId] =
config.DATASOURCE.filter.parents.in_map[ds.dataSourceOrViewId] =
ds.filter.parents.in;
}
if (ds.filter.parents?.not) {
Expand Down

0 comments on commit 50ebf63

Please sign in to comment.