Skip to content

Commit c58e125

Browse files
committed
first init
0 parents  commit c58e125

File tree

10 files changed

+394
-0
lines changed

10 files changed

+394
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to `qwen-laravel` will be documented in this file
4+
5+
## 1.0.0 - 201X-XX-XX
6+
7+
- initial release

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) qwen-php
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# qwen Laravel
2+
3+
Laravel wrapper for **[qwen PHP client](https://github.com/qwen-php/qwen-php-client)** to seamless Alibaba [qwen AI](https://www.qwen.ai) API integration with Laravel applications.
4+
5+
## Table of Contents
6+
7+
- [Installation](#installation)
8+
- [Publishing Configuration File](#publishing-configuration-file)
9+
- [Usage](#usage)
10+
- [Basic Usage](#basic-usage)
11+
- [Advanced Usage](#advanced-usage)
12+
- [Testing](#testing)
13+
- [Contributors](#contributors-)
14+
- [Changelog](#changelog)
15+
- [Security](#security)
16+
- [License](#license)
17+
18+
## Installation
19+
20+
You can install the package via composer:
21+
22+
```bash
23+
composer require qwen-php/qwen-laravel
24+
```
25+
26+
### Publishing Configuration File
27+
28+
```bash
29+
php artisan vendor:publish --tag=qwen
30+
```
31+
then add token to `.env` file
32+
```php
33+
QWEN_API_KEY="your_api_key"
34+
```
35+
36+
## Usage
37+
38+
### Basic Usage
39+
40+
```php
41+
use QwenClient;
42+
43+
$Qwen = app(QwenClient::class);
44+
$response = $Qwen->query('Hello qwen, I am Laravel Framework , how are you Today ^_^ ?')->run();
45+
print_r("qwen API response : " . $response);
46+
```
47+
48+
**Note**: In easy mode, it will take defaults for all configs [Check Default Values](https://github.com/qwen-php/qwen-php-client/blob/master/src/Enums/Configs/DefaultConfigs.php)
49+
50+
### Advanced Usage
51+
52+
```php
53+
use QwenClient;
54+
55+
$Qwen = app(QwenClient::class);
56+
57+
// Another way, with customization
58+
$response = $Qwen
59+
->query('Hello qwen, how are you ?', 'system')
60+
->query('Hello qwen, my name is PHP ', 'user')
61+
->withModel("qwen-chat")
62+
->setTemperature(1.5)
63+
->run();
64+
65+
print_r("qwen API response : " . $response);
66+
```
67+
68+
## Testing
69+
70+
Tests will come soon
71+
72+
## Contributors ✨
73+
74+
Thanks to these wonderful people for contributing to this project! 💖
75+
76+
<table>
77+
<tr>
78+
<td align="center">
79+
<a href="https://github.com/omaralalwi">
80+
<img src="https://avatars.githubusercontent.com/u/25439498?v=4" width="50px;" alt="Omar AlAlwi"/>
81+
<br />
82+
<sub><b>Omar AlAlwi</b></sub>
83+
</a>
84+
<br />
85+
🏆 Creator
86+
</td>
87+
</tr>
88+
</table>
89+
90+
Want to contribute? Check out the [contributing guidelines](./CONTRIBUTING.md) and submit a pull request! 🚀
91+
92+
### Changelog
93+
94+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
95+
96+
### Security
97+
98+
If you discover any security-related issues, please email [[email protected]](mailto:[email protected]) instead of using the issue tracker.
99+
100+
## License
101+
102+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"name": "qwen-php/qwen-laravel",
3+
"description": "A seamless Laravel integration for the qwen PHP client, enabling effortless interaction with the qwen API in your Laravel applications.",
4+
"keywords": [
5+
"qwen-php",
6+
"qwen-laravel",
7+
"qwen-coder",
8+
"qwen-coder",
9+
"alibabaai",
10+
"alibaba-ai",
11+
"alibaba-api",
12+
"alibaba-clout",
13+
"qwen-R1-Zero",
14+
"qwen-chat",
15+
"qwen-math",
16+
"qwen-php-client",
17+
"qwen-api",
18+
"laravel-ai",
19+
"laravel-qwen",
20+
"qwen-package",
21+
"php-qwen",
22+
"qwen-integration",
23+
"qwen-integration",
24+
"openai"
25+
],
26+
"homepage": "https://github.com/qwen-php/qwen-laravel",
27+
"license": "MIT",
28+
"type": "library",
29+
"version": "1.0.0",
30+
"authors": [
31+
{
32+
"name": "qwen-php",
33+
"email": "[email protected]",
34+
"role": "Owner"
35+
},
36+
{
37+
"name": "Omar Alalwi",
38+
"email": "[email protected]",
39+
"role": "creator"
40+
}
41+
],
42+
"require": {
43+
"php": "^8.1.0",
44+
"qwen-php/qwen-php-client": "^1.0.1",
45+
"illuminate/support": "^9.0|^10.0|^11.0",
46+
"nyholm/psr7": "^1.8",
47+
"symfony/http-client": "^7.2"
48+
},
49+
"require-dev": {
50+
"orchestra/testbench": "^7.0|^8.0",
51+
"phpunit/phpunit": "^9.0|^10.0"
52+
},
53+
"autoload": {
54+
"psr-4": {
55+
"Qwen\\QwenLaravel\\": "src"
56+
}
57+
},
58+
"autoload-dev": {
59+
"psr-4": {
60+
"Qwen\\QwenLaravel\\Tests\\": "tests"
61+
}
62+
},
63+
"scripts": {
64+
"test": "vendor/bin/phpunit",
65+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
66+
},
67+
"config": {
68+
"sort-packages": true,
69+
"allow-plugins": {
70+
"php-http/discovery": true
71+
}
72+
},
73+
"extra": {
74+
"laravel": {
75+
"providers": [
76+
"Qwen\\QwenLaravel\\QwenLaravelServiceProvider"
77+
],
78+
"aliases": {
79+
"QwenLaravel": "Qwen\\QwenLaravel\\QwenLaravelFacade"
80+
}
81+
}
82+
}
83+
}

config/qwen.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
use Qwen\Enums\Configs\DefaultConfigs;
4+
5+
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| API Key
10+
|--------------------------------------------------------------------------
11+
|
12+
| The API key used to authenticate requests to the QWEN API. This key
13+
| is required for all API interactions. Ensure that you set this value in
14+
| your environment file (.env) as QWEN_API_KEY to keep it secure.
15+
|
16+
*/
17+
'api_key' => env('QWEN_API_KEY'),
18+
19+
/*
20+
|--------------------------------------------------------------------------
21+
| Base URL
22+
|--------------------------------------------------------------------------
23+
|
24+
| The base URL for the QWEN API. By default, it uses the value defined
25+
| in DefaultConfigs::BASE_URL. You can override this by setting the
26+
| QWEN_API_BASE_URL variable in your environment file if you need to
27+
| connect to a custom endpoint.
28+
|
29+
*/
30+
'base_url' => env('QWEN_API_BASE_URL', (string) DefaultConfigs::BASE_URL->value),
31+
32+
/*
33+
|--------------------------------------------------------------------------
34+
| API Timeout
35+
|--------------------------------------------------------------------------
36+
|
37+
| The maximum time, in seconds, for API requests to complete before timing
38+
| out. This helps prevent your application from waiting indefinitely for
39+
| a response. The default value is taken from DefaultConfigs::TIMEOUT.
40+
| You can override it in the environment file by setting QWEN_API_TIMEOUT.
41+
|
42+
*/
43+
'timeout' => env('QWEN_API_TIMEOUT', (int) DefaultConfigs::TIMEOUT->value),
44+
45+
];
289 KB
Loading

src/Exceptions/ApiKeyIsMissing.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Qwen\QwenLaravel\Exceptions;
6+
7+
use InvalidArgumentException;
8+
9+
/**
10+
* @internal
11+
*/
12+
final class ApiKeyIsMissing extends InvalidArgumentException
13+
{
14+
/**
15+
* Create a new exception instance.
16+
*/
17+
public static function create(): self
18+
{
19+
return new self(
20+
'The qwen API key is not set. Please ensure `Qwen_API_KEY` is configured in your .env file.',
21+
);
22+
}
23+
}

src/QwenLaravelFacade.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Qwen\QwenLaravel;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class QwenLaravelFacade extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'qwen-laravel';
17+
}
18+
}

0 commit comments

Comments
 (0)