![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@salutejs/scenario
Advanced tools
Readme
Библиотека описания структры, матчинга и хендлеров пользовательского сценария.
npm i -S @salutejs/scenario
Словарь описывается локально в файле с заданной схемой. В зависимости от типа рекогнайзера, словарь может синхронизроваться с удалённой моделью распознования.
./src/intents.ts
import { createIntents } from '@salutejs/scenario';
export const intents = createIntents({
openItem: {
matchers: ['покажи', 'открой', 'открой номер'], // фразы, которые будут использованы для тренировки модели
},
slotFilling: {
matchers: ['захвати яблок', 'захвати @number ялок'],
variables: { // сущности, которые необходимо достать из фразы
number: {
required: true, // флаг обязательного присутствия сущности в сессии для продолжения сценария
questions: ['Сколько яблок?', 'Сколько?'],
},
},
},
});
import { createUserScenario } from '@salutejs/scenario';
// ...
const userScenario = createUserScenario({
OpenItemState: { // идентификатор состояния
match: intent('OpenItem'),
handle: ({ req, res }) => {
const { number } = req.variables;
res.appendCommand({ type: 'OpenItem', payload: selectItem({ number })(req) });
},
},
slotFillingState: {
match: intent('slotFilling'),
handle: ({ res, req }) => res.setPronounceText(`Вы попросили ${req.variables.number} яблок`),
},
});
Хелперы декларативного описания условия выполнения хендела на поступивший запрос.
import { createMatchers, createUserScenario, SaluteRequest } from '@salutejs/scenario';
import { intents } from './intents';
// NB: Указание типа запроса и словаря интентов добавляет интерактивный автокомплишен
const { match, intent, text, action, state, selectItem } = createMatchers<SaluteRequest, typeof intents>();
// Матчеры собираются в композицию функцией match
const userScenario = createUserScenario({
state1: {
match: match(intent('OpenItem'), state({ screen: 'main' }),
handle: () => {},
},
state2: {
match: text('да'), // распознование не будет передено в рекогнайзер
handle: () => {},
},
state3: {
match: action('LOAD_DATA'), // матчер на тип, передаваемый в server_action
handle: () => {},
},
});
NLP-платформа обладает набором специальных интентов, которые указывают на жизненный цикл смартапа: run_up
, close_app
. Кроме них случаются ситуации, когда фраза пользователя не попала ни под один матчер состояния. Грубо говоря, мы не поняли что хотел сказать пользователь. Такие состояние описываются в отдельном обработчике системного сценария.
import { createSystemScenario } from '@salutejs/scenario';
const systemScenario = createSystemScenario({
RUN_APP: ({ res }) => { // реакция на запуск смартапа
res.setPronounceText('Привет!');
},
CLOSE_APP: ({ res, session }) => { // реакция на закрытие смартапа
db.save(session);
},
NO_MATCH: ({ res }) => { // реакция на не распознанную реплику
res.setPronounceText('Я не понимаю');
},
});
FAQs
Tiny helpers to make scenario for Salute family
The npm package @salutejs/scenario receives a total of 552 weekly downloads. As such, @salutejs/scenario popularity was classified as not popular.
We found that @salutejs/scenario demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.