Skip to content

Commit df4ef5f

Browse files
committed
first initlize
0 parents  commit df4ef5f

32 files changed

+1274
-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 `sdk` 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: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<p align="center">
2+
<a href="https://qwen-php/qwen-php-client" target="_blank">
3+
<img src="https://raw.githubusercontent.com/qwen-php/qwen-php-client/master/public/images/qwen_screenshot.png" alt="Gpdf">
4+
</a>
5+
</p>
6+
7+
## 🚧 This Project is Under Development!
8+
9+
V1 will Released in few Days .
10+
11+
# qwen PHP Client
12+
13+
## Table of Contents
14+
- [Overview](#Overview)
15+
- [Features](#key-Features)
16+
- [Installation](#installation)
17+
- [Quick Start Guide](#quick-start-guide)
18+
- [Basic Usage](#basic-usage)
19+
- [Advanced Usage](#advanced-usage)
20+
- [Use With Frameworks](#use-with-frameworks)
21+
- [Testing](#testing)
22+
- [Contributors](#contributors-)
23+
- [License](#license)
24+
25+
---
26+
## Overview
27+
**qwen PHP Client** is a robust and community-driven PHP client library for seamless integration with the [Qwen](https://qwenlm.ai/) API.
28+
### Key Features
29+
- **Easy Integration:** Simplifies interaction with the qwen API using a PHP client.
30+
- **Method Chaining:** Supports fluent method chaining for building requests.
31+
- **Customizable:** Allows setting different models, query roles, and streaming options.
32+
- **PSR-18 Compliance:** Utilizes PSR-18 HTTP client for making API requests.
33+
34+
---
35+
36+
## Installation
37+
38+
You can install the package via Composer:
39+
40+
```bash
41+
composer require qwen-php/qwen-php-client
42+
```
43+
44+
**Ensure your project meets the following requirements:**
45+
- PHP 8.1 or later
46+
47+
---
48+
49+
## Quick Start Guide
50+
51+
### Basic Usage
52+
53+
```php
54+
use Qwen\QwenClient;
55+
56+
$apiKey = 'your-api-key';
57+
58+
$response = QwenClient::build($apiKey)
59+
->query('Hello qwen, how are you today?')
60+
->run();
61+
62+
echo 'API Response:'.$response;
63+
```
64+
65+
**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)
66+
67+
### Advanced Usage
68+
69+
```php
70+
use Qwen\QwenClient;
71+
use Qwen\Enums\Queries\QueryRoles;
72+
use Qwen\Enums\Models;
73+
74+
$apiKey = 'your-api-key';
75+
76+
$response = QwenClient::build($apiKey, 'https://dashscope-intl.aliyuncs.com', 500)
77+
->query('System setup query', 'system')
78+
->query('User input message', 'user')
79+
->withModel(Models::CODER->value)
80+
->run();
81+
82+
echo 'API Response:'.$response;
83+
```
84+
85+
## Use With Frameworks
86+
87+
Coming soon
88+
89+
---
90+
91+
## Testing
92+
93+
tests will come soon .
94+
95+
## Changelog
96+
97+
See [CHANGELOG](CHANGELOG.md) for recent changes.
98+
99+
## Contributors ✨
100+
101+
Thanks to these wonderful people for contributing to this project! 💖
102+
103+
<table>
104+
<tr>
105+
<td align="center">
106+
<a href="https://github.com/omaralalwi">
107+
<img src="https://avatars.githubusercontent.com/u/25439498?v=4" width="50px;" alt="Omar AlAlwi"/>
108+
<br />
109+
<sub><b>Omar AlAlwi</b></sub>
110+
</a>
111+
<br />
112+
🏆 Creator
113+
</td>
114+
</tr>
115+
</table>
116+
117+
Want to contribute? Check out the [contributing guidelines](./CONTRIBUTING.md) and submit a pull request! 🚀
118+
119+
## Security
120+
121+
If you discover any security-related issues, please email creator : `[email protected]`.
122+
123+
## License
124+
125+
The MIT License (MIT). See [LICENSE](LICENSE.md) for more information.

composer.json

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"name": "qwen-php/qwen-php-client",
3+
"description": "robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities",
4+
"homepage": "https://github.com/qwen-php/qwen-php-client",
5+
"license": "MIT",
6+
"type": "library",
7+
"keywords": [
8+
"qwen",
9+
"qwen-php-sdk",
10+
"qwen-sdk",
11+
"qwen-api",
12+
"php-qwen",
13+
"alibaba-ai",
14+
"alibaba",
15+
"qwen-coder",
16+
"qwen-integration",
17+
"openai",
18+
"deepseek",
19+
"deepseek-php",
20+
"sdk",
21+
"codex",
22+
"GPT-3",
23+
"DALL-E",
24+
"api",
25+
"client",
26+
"php-sdk",
27+
"php-ai",
28+
"ai-for-php",
29+
"ai-sdk",
30+
"ai-api",
31+
"natural",
32+
"language",
33+
"processing",
34+
"qwen-php-library",
35+
"qwen-client",
36+
"natural-language-processing",
37+
"ai-integration",
38+
"machine-learning",
39+
"php-machine-learning",
40+
"php-iot",
41+
"nlp",
42+
"data-processing",
43+
"deep-learning",
44+
"qwen-library",
45+
"php-library",
46+
"api-integration",
47+
"php-api-client",
48+
"qwen-ai",
49+
"php-openai-alternative",
50+
"ai-client-library"
51+
],
52+
"authors": [
53+
{
54+
"name": "qwen-php",
55+
"email": "[email protected]",
56+
"role": "owner"
57+
},
58+
{
59+
"name": "Omar Alalwi",
60+
"email": "[email protected]",
61+
"role": "creator"
62+
}
63+
],
64+
"version": "1.0.0",
65+
"require": {
66+
"php": "^8.1.0",
67+
"php-http/discovery": "^1.20.0",
68+
"php-http/multipart-stream-builder": "^1.4.2",
69+
"psr/http-client": "^1.0.3",
70+
"psr/http-client-implementation": "^1.0.1",
71+
"psr/http-factory-implementation": "*",
72+
"psr/http-message": "^1.1.0|^2.0.0"
73+
},
74+
"require-dev": {
75+
"guzzlehttp/guzzle": "^7.9.2",
76+
"guzzlehttp/psr7": "^2.7.0",
77+
"laravel/pint": "^1.18.1",
78+
"mockery/mockery": "^1.6.12",
79+
"nunomaduro/collision": "^7.11.0|^8.5.0",
80+
"pestphp/pest": "^2.36.0|^3.5.0",
81+
"pestphp/pest-plugin-arch": "^2.7|^3.0",
82+
"pestphp/pest-plugin-type-coverage": "^2.8.7|^3.1.0",
83+
"phpstan/phpstan": "^1.12.7",
84+
"roave/security-advisories": "dev-latest",
85+
"symfony/var-dumper": "^6.4.11|^7.1.5"
86+
},
87+
"autoload": {
88+
"psr-4": {
89+
"Qwen\\": "src"
90+
}
91+
},
92+
"autoload-dev": {
93+
"psr-4": {
94+
"Qwen\\Tests\\": "tests"
95+
}
96+
},
97+
"scripts": {
98+
"lint": "pint -v",
99+
"test:lint": "pint --test -v",
100+
"test:types": "phpstan analyse --ansi",
101+
"test:type-coverage": "pest --type-coverage --min=100",
102+
"test:unit": "pest --colors=always",
103+
"test": [
104+
"@test:lint",
105+
"@test:types",
106+
"@test:type-coverage",
107+
"@test:unit"
108+
]
109+
},
110+
"config": {
111+
"sort-packages": true,
112+
"preferred-install": "dist",
113+
"allow-plugins": {
114+
"pestphp/pest-plugin": true,
115+
"php-http/discovery": true
116+
}
117+
}
118+
}

public/qwen_screenshot.png.png

15.8 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Qwen\Contracts;
4+
5+
use Qwen\DeepseekClient;
6+
7+
interface DeepseekClientContract
8+
{
9+
public static function build(string $apiKey): self;
10+
public function run(): string;
11+
public function query(string $content, ?string $role = "user"): self;
12+
public function withModel(?string $model = null): self;
13+
public function withStream(bool $stream = true): self;
14+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Qwen\Contracts\Factories;
4+
5+
use Qwen\Factories\ApiFactory;
6+
use GuzzleHttp\Client;
7+
8+
interface ApiFactoryContract
9+
{
10+
/**
11+
* Create a new instance of the factory.
12+
*
13+
* @return ApiFactory
14+
*/
15+
public static function build(): ApiFactory;
16+
17+
/**
18+
* Set the base URL for the API.
19+
*
20+
* @param string|null $baseUrl The base URL to set (optional).
21+
* @return ApiFactory
22+
*/
23+
public function setBaseUri(?string $baseUrl = null): ApiFactory;
24+
25+
/**
26+
* Set the API key for authentication.
27+
*
28+
* @param string $apiKey The API key to set.
29+
* @return ApiFactory
30+
*/
31+
public function setKey(string $apiKey): ApiFactory;
32+
33+
/**
34+
* Set the timeout for the API request.
35+
*
36+
* @param int|null $timeout The timeout value in seconds (optional).
37+
* @return ApiFactory
38+
*/
39+
public function setTimeout(?int $timeout = null): ApiFactory;
40+
41+
/**
42+
* Build and return the Guzzle Client instance.
43+
*
44+
* @return Client
45+
*/
46+
public function run(): Client;
47+
}

0 commit comments

Comments
 (0)