For making a system more reliable and robust, continuous evaluation is quite important. So is in the case of SUSI AI. User feedback is important to improve SUSI skills and create new ones. Previously we had only thumbs up / thumbs down as a feedback method, from the SUSI chat client. But now a 5 star rating system has been added to the SUSI Skill CMS so that users can rate a skill there. Before the implementation of API let’s look how data is stored in SUSI AI Susi_server uses DAO in which skill rating is stored as JSONTray. The rating system has been implemented on SkillListing.js file on the CMS.
The CMS side
- Install the Recharts Data Visualization library.
- Install the Rating library for react.
- Import the Barchart, Cell, LabelList, Bar, XAxis, YAxis and Tooltip components from Recharts.
- Import the Ratings components from React Ratings Declarative.
- Add average rating, total ratings, rating counts on each star and rating given by the users as state variables.
- Load the skill ratings as soon as the page loads. getSkillRating.json API is used to get skill ratings. Fetch the stars related data from the API response and save them in the state variable using saveSkillRatings() function.
- Store the skills rating data to be visualized on the charts. The rating data is kept in an array and store in a state variable. Put zero if the rating count is not available. This state variable is used by the Recharts library as an input for data visualization.
- Create a function to that informs the server about the rating given by the current user. The changeRating() function calls the fiveStarRateSkill.json API with the parameters like who has rated the skill and what rating has been given.
- Check if the user is logged in and display the rating bar. The rating bar should appear only if the user is logged in. The document’s cookies hold the information about the logged in user.
- Display the BarChart of existing ratings, total ratings and average rating. It shows the count on each star.
If the average rating is available in the state then show it, otherwise put zero in the average rating.
Add a Bar Chart and define the data to be visualized i.e. the skill rating data. The Y-axis of the chart maps to the particular rating and the X-axis shows the count of that rating. The value of bar and label is set from the count of each star rating.
If the total number of ratings is available in the state then show it, otherwise put zero in the total number of ratings.
So this 5 star rating system will help in improving the SUSI skills. Also, it will help in making better decisions when we have multiple similar skills and we have to choose one to respond to the user query.
- Server side implementation – https://blog.fossasia.org/tag/5-star-rating/