Skip to content

Commit 38e7981

Browse files
authored
Merge pull request #3 from deepseek-php/feat/support-temperature-option
feat support temperature option
2 parents a9b127f + 0571779 commit 38e7981

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
build
2+
vendor
3+
tests/TestSupport/temp
4+
tests/temp
5+
composer.lock
6+
phpunit.xml
7+
.env
8+
.phpunit.cache/
9+
.phpunit.result.cache
10+
.phpunit.cache/test-results
11+
.php-cs-fixer.cache
12+
phpstan.neon
13+
tests/Support/temp/
14+
.idea/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ $response = DeepseekClient::build($apiKey, 'https://api.deepseek.com/v2', 500)
7373
->query('System setup query', 'system')
7474
->query('User input message', 'user')
7575
->withModel(Models::CODER->value)
76+
->setTemperature(1.5)
7677
->run();
7778

7879
echo 'API Response:'.$response;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"role": "creator"
6060
}
6161
],
62-
"version": "1.0.0.0",
62+
"version": "1.0.2",
6363
"require": {
6464
"php": "^8.1.0",
6565
"php-http/discovery": "^1.20.0",

src/DeepseekClient.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class DeepseekClient implements DeepseekClientContract
4343
*/
4444
protected bool $stream;
4545

46+
protected int $temperature;
47+
4648
/**
4749
* Initialize the DeepseekClient with a PSR-compliant HTTP client.
4850
*
@@ -61,6 +63,7 @@ public function run(): string
6163
QueryFlags::MESSAGES->value => $this->queries,
6264
QueryFlags::MODEL->value => $this->model,
6365
QueryFlags::STREAM->value => $this->stream,
66+
QueryFlags::TEMPERATURE->value => $this->temperature,
6467
];
6568
// Clear queries after sending
6669
$this->queries = [];
@@ -123,6 +126,12 @@ public function withStream(bool $stream = true): self
123126
return $this;
124127
}
125128

129+
public function setTemperature(int $temperature): self
130+
{
131+
$this->temperature = $temperature;
132+
return $this;
133+
}
134+
126135
protected function buildQuery(string $content, ?string $role = null): array
127136
{
128137
return [

src/Enums/Requests/QueryFlags.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ enum QueryFlags: string
77
case MESSAGES = 'messages';
88
case MODEL = 'model';
99
case STREAM = 'stream';
10+
case TEMPERATURE = 'temperature';
1011
}

0 commit comments

Comments
 (0)