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

feat: add visualization card in customized parser #16

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Nov 27, 2023

Description

Parse out visualization message if the final response is generated by visualization tool.

image

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@SuZhou-Joe SuZhou-Joe changed the title feat: add implement visualization in customized parser feat: add visualization card in customized parser Nov 27, 2023
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a good place to add some unit tests for the parser :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, added cases accordingly.

async parserProvider(interaction: Interaction) {
const additionalInfo = interaction.additional_info as {
'VisualizationTool.output': string[];
};
Copy link
Member

Choose a reason for hiding this comment

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

This type doesn't seem right, on line 21, additionalInfo is nullable, but additional_info in Interaction is Record<string, unknown>. Is additional_info actually optional field?

Copy link
Member

Choose a reason for hiding this comment

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

i think assertion should happen after field check

return lines
.map((line) => line.split(',').at(column))
.filter(<T>(v: T | null | undefined): v is T => v !== null && v !== undefined);
};
Copy link
Member

Choose a reason for hiding this comment

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

could you add the TODO comment

// TODO use a more robust CSV parsing library
const extractNthColumn = (csv: string, column: number) => {

theoretically id can contain any character, i haven't tested whether " in ids would be encoded or left as is, but current logic is not enough either way

also should output_builders/saved_objects.ts be removed? and could there be some tests similar to

Copy link
Member Author

Choose a reason for hiding this comment

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

I am using csv-parser package, which is a popular and robust package to handle with csv format.

And sure, I migrate the test cases in save_objects.test.ts and add some edge cases.

};

export const VisualizationCardParser = {
id: 'core_visualization',
Copy link
Member

Choose a reason for hiding this comment

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

should there be an order explicitly? and i remember parsers should use the MessageParser interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

If order is not specified, default order value will be 999.

Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
server/parsers/visualization_card_parser.ts Outdated Show resolved Hide resolved
Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

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

lgtm

Signed-off-by: SuZhou-Joe <[email protected]>
@SuZhou-Joe SuZhou-Joe merged commit 37eaa5c into feature/agent-framework Nov 29, 2023
12 checks passed
@SuZhou-Joe SuZhou-Joe deleted the feature/visualization-card branch December 1, 2023 03:14
SuZhou-Joe added a commit that referenced this pull request Dec 1, 2023
* feat: add implement visualization in customized parser

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add csv-parser lib

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add csv-parser lib

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add test cases

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhou-Joe <[email protected]>
SuZhou-Joe added a commit that referenced this pull request Dec 5, 2023
* feat: add implement visualization in customized parser

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add csv-parser lib

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add csv-parser lib

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add test cases

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhou-Joe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants