Skip to content

Commit

Permalink
fix: remove duplicate visualizations (#49)
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe authored Dec 6, 2023
1 parent 2155b00 commit 3f08771
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions server/parsers/visualization_card_parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,37 @@ describe('VisualizationCardParser', () => {
},
]);
});

it('filter duplicate visualization id in a single interaction', async () => {
expect(
await VisualizationCardParser.parserProvider({
input: 'input',
response: 'response',
conversation_id: '',
interaction_id: 'interaction_id',
create_time: '',
additional_info: {
'VisualizationTool.output': [
'row_number,Id,title\n' +
'1,id1,[Flights] Total Flights\n' +
'2,id2,[Flights] Total Flights\n',
'row_number,Id,title\n' + '2,id2,[Flights] Controls\n',
],
},
})
).toEqual([
{
content: 'id1',
contentType: 'visualization',
suggestedActions: [{ actionType: 'view_in_dashboards', message: 'View in Visualize' }],
type: 'output',
},
{
content: 'id2',
contentType: 'visualization',
suggestedActions: [{ actionType: 'view_in_dashboards', message: 'View in Visualize' }],
type: 'output',
},
]);
});
});
2 changes: 1 addition & 1 deletion server/parsers/visualization_card_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const VisualizationCardParser = {
await Promise.all(visualizationOutputs.map((output) => extractIdsFromCsvString(output)))
).flatMap((id) => id);

const visOutputs: IMessage[] = visualizationIds
const visOutputs: IMessage[] = [...new Set(visualizationIds)]
/**
* Empty id will be filtered
*/
Expand Down

0 comments on commit 3f08771

Please sign in to comment.