Skip to content

Commit 2b7b0db

Browse files
authored
Merge pull request #1 from A909M/fix/config-handling-and-missing-apikey
Fix: Handle DefaultConfigs values correctly and add ApiKeyIsMissing e…
2 parents 256957d + c5a4188 commit 2b7b0db

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"homepage": "https://github.com/deepseek-php/deepseek-laravel",
2121
"license": "MIT",
2222
"type": "library",
23-
"version": "1.0.0",
23+
"version": "1.0.0.0,
2424
"authors": [
2525
{
2626
"name": "deepseek-php",

config/deepseek.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
| connect to a custom endpoint.
2828
|
2929
*/
30-
'base_url' => env('DEEPSEEK_API_BASE_URL', DefaultConfigs::BASE_URL),
30+
'base_url' => env('DEEPSEEK_API_BASE_URL', (string) DefaultConfigs::BASE_URL->value),
3131

3232
/*
3333
|--------------------------------------------------------------------------
@@ -40,6 +40,6 @@
4040
| You can override it in the environment file by setting DEEPSEEK_API_TIMEOUT.
4141
|
4242
*/
43-
'timeout' => env('DEEPSEEK_API_TIMEOUT', DefaultConfigs::TIMEOUT),
43+
'timeout' => env('DEEPSEEK_API_TIMEOUT', (int) DefaultConfigs::TIMEOUT->value),
4444

4545
];

src/DeepseekLaravelServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DeepseekPhp\DeepseekClient;
66
use Illuminate\Support\ServiceProvider;
7+
use DeepseekPhp\DeepseekLaravel\Exceptions\ApiKeyIsMissing;
78

89
class DeepseekLaravelServiceProvider extends ServiceProvider
910
{
@@ -29,6 +30,10 @@ public function register()
2930
$baseUrl = config('deepseek.base_url');
3031
$timeout = config('deepseek.timeout');
3132

33+
if (! is_string($apiKey)) {
34+
throw ApiKeyIsMissing::create();
35+
}
36+
3237
return DeepseekClient::build($apiKey, $baseUrl, $timeout);
3338
});
3439
}

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 DeepseekPhp\DeepseekLaravel\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 Deepseek API key is not set. Please ensure `DEEPSEEK_API_KEY` is configured in your .env file.',
21+
);
22+
}
23+
}

0 commit comments

Comments
 (0)