A skill is a set of intents. One text file represents one skill, it may contain several intents which all belong together. All the skills are stored in Susi Skill Data repository and the schema is Models -> Groups -> Languages -> Skill -> Intents. Using this, one can access any skill based on four tuples parameters model, group, language, skill. Susi skill CMS is an editor to write and edit skill easily. It follows an API-centric approach where the Susi server acts as API server and a web front-end act as the client for the API and provides the user interface.
To give more information of a Skill above metadata was added to the text file. Where dynamic content, represents if the skill answer changes based on user inputs. And image is the path to image of the skill, stored in skill data repository. Let’s check how this is implemented in Susi Server.
Susi Skill class provides parser methods for sets of intents, given as text files. It reads the skill line by line. For differentiating skill metadata with skill code we have use (::) operator. If a line starts with ::, method knows it’s skill metadata, and process it respectively. It takes out the respective substring and puts in json to be later processed by SusiMind class.
The SusiMind class process this json and stores the metadata in a map of skill path and data.This map is used by GetSkillMetadataService class to to list the skill metadata for all the skills given its model, group and language and skill. For adding the servlet we need to inherit the service class from AbstractAPIHandler and implement APIhandler interface.In Susi Server an abstract class AbstractAPIHandler extending HttpServelets and implementing API handler interface is provided.
The getAPIPath() methods sets the API endpoint path, it gets appended to base path which is 127.0.0.1:4000/cms/getSkillMetadata.json for local host. The getMinimalBaseRole method tells the minimum Userrole required to access this servlet it can also be ADMIN, USER. In our case it is Anonymous. A User need not to log in to access this endpoint.
In Serviceimpl method,
We can get the required parameters through call.get() method where first parameter is the key for which we want to get the value and second parameter is the default value. If the path contains the desired language, group and model and skill, we return it as a response containing the respective field. The endpoint can be tested http://127.0.0.1:4000/cms/getSkillMetadata.json?group=general&model=entertainment&language=en&skill=cat and you will get the following response.
This is how getSKillMetadata service works. To add the metadata to the skill visit susi_skill_data, the storage place for susi skills. For more information and complete code take a look at Susi server and join gitter chat channel for discussions.
- Read more about Servets – https://www.tutorialspoint.com/servlets/
- The source code –https://github.com/fossasia/susi_server/blob/development/src/ai/susi/server/api/cms/
- Read about servlet interface – https://www.javatpoint.com/Servlet-interface