一个轮子 tencent-ai 腾讯 AI 开放平台 SDK
2018-06-26 本文已影响109人
独步弈城
tencent-ai是 腾讯AI开放平台 SDK
项目地址:https://github.com/justmd5/tencent-ai
欢迎前来 star 以及提 issue !
Requirement
- PHP >= 7.0
- Composer
- ext-curl 拓展
- ext-json 拓展
Install
$ composer require justmd5/tencent-ai:dev-master
Usage
$config = [
'appKey' => '1106944xxx',
'appSecret' => 'dsgnbnWnX8Yxxxxxx',
'debug' => 0,//1 show debug info
];
$AI = new \Justmd5\TencentAi\Ai($config);
Interface call example
$params = [
'question'=>'腾讯人工智能',
'session'=>123,
];
try {
dd($AI->nlp->request('textchat', $params));
} catch (\Justmd5\TencentAi\Exception\NotFoundException $e) {
dd($e);
}
当然laravel版的少不了啦
项目地址:https://github.com/justmd5/laravel-tencent-ai
Install
in your laravel application, execute the following command:
composer require justmd5/laravel-tencent-ai:dev-master
Configure
add service provider to the app.php:
'providers' => [
// Application Service Providers...
Justmd5\LaravelTencentAi\ServiceProvider::class,
],
if you use laravel that >= 5.5 ,the above steps are not required.
publish config:
php artisan vendor:publish --provider="Justmd5\LaravelTencentAi\ServiceProvider"
after that, you might want to change some config about tencentai:
// config/tencentai.php
return [
'appKey' => '',
'appSecret' => '',
'debug' => 0,
];
Usage
$params = [
'question'=>'腾讯人工智能',
'session'=>123,
];
dd(app('tencent-ai')->nlp->request('textchat', $params));
Documentation
Tencent AI · Official Documents
Help
qq群
image