<commit_before>import {BotFrameworkActivity} from "../definitions/BotFrameworkService";
import {ResponseModel} from "../definitions/Handler";
import {View} from "../definitions/Views";

new View("BotFrameworkActivity", (model: ResponseModel, activity: BotFrameworkActivity) => {

    let response = {
        "type": "message",
        "from": activity.recipient,
        "conversation": activity.conversation,
        "locale": activity.locale,
        "recipient": activity.from,
        "text":  model.speech,
        "speak": model.speech,
        "inputHint": "expectingInput",
        "replyToId": activity.id
    } as BotFrameworkActivity;

    return response;
});<commit_msg>Render hero cards for Cortana responses.<commit_after>import {BotFrameworkActivity, BotFrameworkAttachment} from "../definitions/BotFrameworkService";
import {ResponseModel} from "../definitions/Handler";
import {Items, Purchaseable} from "../definitions/Inventory";
import {View} from "../definitions/Views";

new View("BotFrameworkActivity", (model: ResponseModel, activity: BotFrameworkActivity) => {

    let CookieAction = {
        text: "Cookie",
        title: "Cookie Time",
        type: "postBack",
        value: "bake more cookies",
    };

    let UpgradesAction = {
        text: "Upgrades",
        title: "Check Upgrades",
        type: "postBack",
        value: "check for upgrades",
    };

    let EatAction = {
        text: "eat",
        title: "Eat a Cookie!",
        type: "postBack",
        value: "eat a cookie",
    };

    let HelpAction = {
        text: "Help",
        title: "Help",
        type: "postBack",
        value: "help",
    };

    let card = {
        title: "Cookie Time",
        text: "Tap this card to bake more cookies!",
        tap: CookieAction,
        buttons: [CookieAction]
    };

    if (model.cookieCount) {
        card.title = "Cookie Count: " + model.cookieCount.toFormat(0);
    }

    if (model.upgrades.length > 0) {

        model.upgrades.forEach(upgrade => {
            let item: Purchaseable = Items.All[upgrade];
            console.log("upgrade: " + upgrade);
            console.log("item:" + JSON.stringify(item));
            card.buttons.push(
                {
                    text: "Upgrade",
                    title: "Buy: " + item.id,
                    type: "postBack",
                    value: item.description,
                }
            );
        });
    } else {
        card.buttons.push(UpgradesAction);
    }

    card.buttons.push(EatAction, HelpAction);

    let Attachment = {
        contentType: "application/vnd.microsoft.card.hero",
        content: card,
        name: "Cookie Card",
    } as BotFrameworkAttachment;

    let response = {
        type: "message",
        from: activity.recipient,
        conversation: activity.conversation,
        locale: activity.locale,
        recipient: activity.from,
        speak: model.speech,
        inputHint: "expectingInput",
        replyToId: activity.id,
        attachments: [Attachment],
    } as BotFrameworkActivity;

    if (activity.channelId === "webchat" && model.upgrades.length < 1) {
        response.text = model.speech;
    }

    return response;
});
{'fraction_non_alphanumeric': 0.1302860696517413, 'fraction_numerical': 0.0009328358208955224, 'mean_word_length': 2.2105788423153694, 'pattern_counts': {'":': 9, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3498131', 'n_tokens_mistral': 919, 'n_tokens_neox': 877, 'n_words': 212}