Frontend - natural language querying in visualization designer
Implement frontend for natural language querying within visualization designer AI experiment.
Design
Initial crappy mockup, just a jumping off point, we might want to do something completely different
Assumptions:
- New AI prompt component should happen earlier in the flow than selecting measures/dimensions etc, since it will overwrite these selections. Perhaps the main viz designer should go into a loading/disabled state after submitting
- Once prompt returns, we will apply the generated query. This will cause the viz designer UI to update to reflect the generated query, and allow further editing (e.g. measures / time dimensions etc will be selected)
- Data will be fetched when the generated query is returned, so it can be previewed
- We will need to handle the model returning us garbage responses / invalid queries
- Loading time could be slow
Implementation plan
- Consume new feature flag added in backend implementation plan
- If enabled, add new component to viz designer for natural language querying
- Design TBD
- Component consumes the AI GraphQL endpoint: https://docs.gitlab.com/ee/development/ai_features/#graphql-api
- Sends mutation with new ai action type, and
prompt
containing the users prompt (or one of our preset examples, if we end up having those) - subscribes to
aiCompletionResponse
and waits for generated CubeJS query. Put the query builder into some disabled / loading state, so users do't select options that get overridden when the response comes back. - When query comes back, set
queryState
on the viz designer, which will update the CubeJS QueryBuilder, all UI, and fetch the data - Handle bad / invalid / unsupported queries
- Manually set the limit on the generated query? We default to
limit: 100
within viz designer, I guess we should preserve that to help keep load down
Questions:
- How do we want to deal with dates / date ranges on the generated query? The model will happily generate a query filtered to a specific range, but the viz designer doesn't have any UI for this.
- strip it out? Could be confusing if the user specifically asks for "Count of users in November 2023"
- add date filtering to viz designer? Additional work, but kinda nice to have anyway as viz designer is our place to explore your data
- Whatever gets set will get overridden on the dashboard anyway, so there's potentially not a good fit
- Should we apply our "unsaved changes" logic to prevent submitting the AI prompt when you have made changes in the viz designer? (or a modified version of it, e.g. title/viz type won't get reset so don't worry about that)
Edited by Elwyn Benson