PHP code example of commune / compnt-rasa

1. Go to this page and download the library: Download commune/compnt-rasa library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

commune / compnt-rasa example snippets



// 机器人配置数组 ChatbotConfig

return [
    ...

    'components' => [
        ...

        Commune\Components\Rasa\RasaComponent::class => [
            // rasa http api 地址
            'server' => 'localhost:5005',

            // 如果通过 jwt 验证的话
            'jwt' => '',

            // 意图的置信度, 高于 0.7 才加入 highlyPossibleIntent
            'threshold' => 70,

            // 语料库同步的目标文件位置
            'output' => __DIR__ .'/resources/rasa.md',

            // rasa domain.md 的文件位置
            'domainOutput' => __DIR__ . '/resources/domain.yml',

            // 使用 Guzzle 调用 Rasa api 时的配置
            'clientConfig' => [
                'timeout' => 0.3,
            ],
        ],

        NLUComponent::class => [
            'nluServices' => [
                ...
                Commune\Components\Rasa\Services\RasaService::class,
            ]

        ],
    ],

    ...

    'host' => [
        ...

        'sessionPipes' => [
            ...
            Commune\Components\Rasa\RasaSessionPipe::class,
        ]
        ...
    ],

]