public constructor()

in templates/typescript/generator-bot-virtualassistant/generators/skill/templates/sample-skill/src/services/botServices.ts [22:82]


    public constructor(settings: IBotSettings, client: BotTelemetryClient) {
        settings.cognitiveModels.forEach((value: CognitiveModelConfiguration, key: string): void => {

            const language: string = key;
            const config: CognitiveModelConfiguration = value;

            const telemetryClient: BotTelemetryClient = client;

            const luisOptions: LuisRecognizerOptionsV3 = {
                telemetryClient: telemetryClient,
                logPersonalInformation: true,
                apiVersion: 'v3'
            };

            const set: Partial<ICognitiveModelSet> = {
                luisServices: new Map(),
                qnaConfiguration: new Map(),
                qnaServices: new Map()
            };
            if (config.dispatchModel !== undefined) {
                const dispatchModel: LuisService = new LuisService(config.dispatchModel);
                const dispatchApp: LuisApplication = {
                    applicationId: dispatchModel.appId,
                    endpointKey: dispatchModel.subscriptionKey,
                    endpoint: dispatchModel.getEndpoint()
                };

                set.dispatchService= new LuisRecognizer(dispatchApp, luisOptions);
            }
            
            if (config.languageModels !== undefined) {
                config.languageModels.forEach((model: LuisService): void => {
                    const luisModel: LuisService = new LuisService(model);
                    const luisApp: LuisApplication  = {
                        applicationId: luisModel.appId,
                        endpointKey: luisModel.subscriptionKey,
                        endpoint: luisModel.getEndpoint()
                    };

                    if (set.luisServices !== undefined) {
                        set.luisServices.set(model.id, new LuisRecognizer(luisApp, luisOptions));
                    }
                });
            }

            if (config.knowledgeBases !== undefined) {
                config.knowledgeBases.forEach((kb: QnaMakerService): void => {
                    const qnaEndpoint: QnAMakerEndpoint = {
                        knowledgeBaseId: kb.kbId,
                        endpointKey: kb.endpointKey,
                        host: kb.hostname
                    };

                    if (set.qnaServices !== undefined) {
                        set.qnaServices.set(kb.id, new QnAMaker(qnaEndpoint, undefined, client, true));
                    }
                });
            }
            this.cognitiveModelSets.set(language, set);
        });
    }