Skip to content

Commit 27fdc5e

Browse files
author
justmd5
committed
init
0 parents  commit 27fdc5e

File tree

10 files changed

+262
-0
lines changed

10 files changed

+262
-0
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = false
10+
11+
[*.{vue,js,scss}]
12+
charset = utf-8
13+
indent_style = space
14+
indent_size = 2
15+
end_of_line = lf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
/tests export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.scrutinizer.yml export-ignore
7+
.travis.yml export-ignore
8+
phpunit.php export-ignore
9+
phpunit.xml.dist export-ignore
10+
phpunit.xml export-ignore
11+
.php_cs export-ignore

.php_cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
$header = <<<EOF
3+
This file is part of the justmd5/laravel-tencent-ai.
4+
5+
(c) 丁海军 <[email protected]>
6+
7+
This source file is subject to the MIT license that is bundled.
8+
EOF;
9+
10+
return PhpCsFixer\Config::create()
11+
->setRiskyAllowed(true)
12+
->setRules(array(
13+
'@Symfony' => true,
14+
'header_comment' => array('header' => $header),
15+
'array_syntax' => array('syntax' => 'short'),
16+
'ordered_imports' => true,
17+
'no_useless_else' => true,
18+
'no_useless_return' => true,
19+
'php_unit_construct' => true,
20+
'php_unit_strict' => true,
21+
))
22+
->setFinder(
23+
PhpCsFixer\Finder::create()
24+
->exclude('vendor')
25+
->in(__DIR__)
26+
)
27+
;

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<h1 align="center">腾讯AI开放平台 SDK</h1>
2+
3+
<p align="center">Tencent AI open platform sdk</p>
4+
5+
<p align="center">
6+
<a href="https://packagist.org/packages/justmd5/laravel-tencent-ai"><img src="https://img.shields.io/packagist/php-v/justmd5/laravel-tencent-ai.svg" alt="PHP from Packagist"></a>
7+
<a href="https://packagist.org/packages/justmd5/laravel-tencent-ai"><img src="https://img.shields.io/github/stars/justmd5/laravel-tencent-ai.svg?style=social&label=Stars" alt="GitHub stars"></a>
8+
<a href="https://packagist.org/packages/justmd5/laravel-tencent-ai"><img src="https://poser.pugx.org/justmd5/laravel-tencent-ai/v/stable.svg" alt="Latest Stable Version"></a>
9+
<a href="https://packagist.org/packages/justmd5/laravel-tencent-ai"><img src="https://poser.pugx.org/justmd5/laravel-tencent-ai/v/unstable.svg" alt="Latest Unstable Version"></a>
10+
<a href="https://packagist.org/packages/justmd5/laravel-tencent-ai"><img src="https://img.shields.io/github/license/justmd5/laravel-tencent-ai.svg" alt="License"></a>
11+
</p>
12+
13+
## Requirement
14+
1. PHP >= 7.0
15+
2. **[Composer](https://getcomposer.org/)**
16+
3. ext-curl 拓展
17+
4. ext-json 拓展
18+
19+
## Install
20+
in your laravel application, execute the following command:
21+
22+
`composer require justmd5/laravel-tencent-ai:dev-master`
23+
## Configure
24+
add service provider to the app.php:
25+
26+
```
27+
'providers' => [
28+
// Application Service Providers...
29+
Justmd5\LaravelTencentAi\ServiceProvider::class,
30+
],
31+
```
32+
> if you use laravel that >= 5.5 ,the above steps are not required.
33+
34+
publish config:
35+
```shell
36+
php artisan vendor:publish --provider="Justmd5\LaravelTencentAi\ServiceProvider"
37+
```
38+
39+
after that, you might want to change some config about tencentai:
40+
```php
41+
// config/tencentai.php
42+
return [
43+
'appKey' => '',
44+
'appSecret' => '',
45+
'debug' => 0,
46+
];
47+
```
48+
49+
## Usage
50+
51+
```php
52+
$params = [
53+
'question'=>'腾讯人工智能',
54+
'session'=>123,
55+
];
56+
57+
dd(app('tencent-ai')->nlp->request('textchat', $params));
58+
59+
```
60+
61+
## Documentation
62+
[Tencent AI](https://ai.qq.com) · [Official Documents](https://ai.qq.com/doc/index.shtml)
63+
### Help
64+
qq群
65+
66+
<p align="center">
67+
<img width="200" src="https://ws1.sinaimg.cn/mw690/bc1dfc6agy1fsmg3zak6cj20f00kk7ei.jpg">
68+
</p>
69+
70+
71+
### Thanks
72+
73+
- thanks to [hanson/foundation-sdk](https://github.com/Hanson/foundation-sdk)
74+
75+
## License
76+
77+
MIT
78+

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "justmd5/laravel-tencent-ai",
3+
"description": "腾讯AI开放平台sdk.",
4+
"keywords": [
5+
"tencent",
6+
"tencent-ai",
7+
"laravel tencent-ai",
8+
"ai-sdk",
9+
"sdk"
10+
],
11+
"type": "library",
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "丁海军",
16+
"email": "[email protected]"
17+
}
18+
],
19+
"autoload": {
20+
"psr-4": {
21+
"Justmd5\\LaravelTencentAi\\": "src/"
22+
}
23+
},
24+
"extra": {
25+
"laravel": {
26+
"providers": [
27+
"Justmd5\\LaravelTencentAi\\ServiceProvider"
28+
],
29+
"aliases": {
30+
"TencentAi": "Justmd5\\LaravelTencentAi\\Facades\\AI"
31+
}
32+
}
33+
},
34+
"require": {
35+
"php": ">=7.0",
36+
"ext-curl": "*",
37+
"ext-json": "*",
38+
"justmd5/tencent-ai": "0.1"
39+
},
40+
"require-dev": {
41+
}
42+
}

phpunit.xml.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<testsuites>
13+
<testsuite name="Application Test Suite">
14+
<directory>./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
</phpunit>

publishes/config.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Created for laravel-tencent-ai
4+
* User: 丁海军
5+
* Date: 2018/6/25
6+
* Time: 上午10:12
7+
*/
8+
return [
9+
'appKey' => '',
10+
'appSecret' => '',
11+
'debug' => 0,
12+
];

src/.gitkeep

Whitespace-only changes.

src/ServiceProvider.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Created for laravel-tencent-ai
4+
* User: 丁海军
5+
* Date: 2018/6/25
6+
* Time: 上午9:50
7+
*/
8+
namespace Justmd5\LaravelTencentAi;
9+
10+
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
11+
use Justmd5\TencentAi\Ai;
12+
13+
class ServiceProvider extends LaravelServiceProvider
14+
{
15+
/**
16+
* Indicates if loading of the provider is deferred.
17+
*
18+
* @var bool
19+
*/
20+
protected $defer = true;
21+
22+
public function boot ()
23+
{
24+
$this->publishes([realpath(__DIR__ . '/../publishes/config.php') => config_path('tencentai.php')], 'laravel-tencent-ai');
25+
}
26+
27+
/**
28+
* Register the provider.
29+
*/
30+
public function register ()
31+
{
32+
$this->app->singleton(Ai::class, function () {
33+
return new Ai(config('tencentai'));
34+
});
35+
$this->app->alias(Ai::class, 'tencent-ai');
36+
}
37+
38+
/**
39+
* Get the services provided by the provider.
40+
*
41+
* @return array
42+
*/
43+
public function provides ()
44+
{
45+
return [
46+
Ai::class,
47+
'tencent-ai',
48+
];
49+
}
50+
}

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)