Skip to content

Commit 09512cc

Browse files
committed
first init
0 parents  commit 09512cc

File tree

9 files changed

+381
-0
lines changed

9 files changed

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

composer.json

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

config/deepseek.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
use DeepseekPhp\Enums\Configs\DefaultConfigs;
4+
5+
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| API Key
10+
|--------------------------------------------------------------------------
11+
|
12+
| The API key used to authenticate requests to the Deepseek API. This key
13+
| is required for all API interactions. Ensure that you set this value in
14+
| your environment file (.env) as DEEPSEEK_API_KEY to keep it secure.
15+
|
16+
*/
17+
'api_key' => env('DEEPSEEK_API_KEY'),
18+
19+
/*
20+
|--------------------------------------------------------------------------
21+
| Base URL
22+
|--------------------------------------------------------------------------
23+
|
24+
| The base URL for the Deepseek API. By default, it uses the value defined
25+
| in DefaultConfigs::BASE_URL. You can override this by setting the
26+
| DEEPSEEK_API_BASE_URL variable in your environment file if you need to
27+
| connect to a custom endpoint.
28+
|
29+
*/
30+
'base_url' => env('DEEPSEEK_API_BASE_URL', DefaultConfigs::BASE_URL),
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 DEEPSEEK_API_TIMEOUT.
41+
|
42+
*/
43+
'timeout' => env('DEEPSEEK_API_TIMEOUT', DefaultConfigs::TIMEOUT),
44+
45+
];

src/DeepseekLaravelFacade.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace DeepseekPhp\DeepseekLaravel;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class DeepseekLaravelFacade 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 'deepseek-laravel';
17+
}
18+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace DeepseekPhp\DeepseekLaravel;
4+
5+
use DeepseekPhp\DeepseekClient;
6+
use Illuminate\Support\ServiceProvider;
7+
8+
class DeepseekLaravelServiceProvider extends ServiceProvider
9+
{
10+
public function boot()
11+
{
12+
if ($this->app->runningInConsole()) {
13+
$this->publishes([
14+
__DIR__.'/../config/deepseek.php' => config_path('deepseek.php'),
15+
], 'deepseek');
16+
17+
}
18+
}
19+
20+
/**
21+
* Register the application services.
22+
*/
23+
public function register()
24+
{
25+
$this->mergeConfigFrom(__DIR__.'/../config/deepseek.php', 'deepseek');
26+
27+
$this->app->singleton('DeepseekClient', function () {
28+
$apiKey = config('deepseek.api_key');
29+
$baseUrl = config('deepseek.base_url');
30+
$timeout = config('deepseek.timeout');
31+
32+
return DeepseekClient::build($apiKey, $baseUrl, $timeout);
33+
});
34+
}
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Feature;
4+
5+
use DeepseekClient;
6+
use DeepseekPhp\Enums\Configs\DefaultConfigs;
7+
use Illuminate\Support\Facades\Config;
8+
use Orchestra\Testbench\TestCase;
9+
10+
class DeepseekLaravelTest extends TestCase
11+
{
12+
/** @test */
13+
public function it_can_query_using_the_deepseek_client()
14+
{
15+
// soon
16+
}
17+
18+
/** @test */
19+
public function it_uses_default_configurations()
20+
{
21+
// soon
22+
}
23+
}

0 commit comments

Comments
 (0)