Skip to content

Commit

Permalink
Merge pull request #3 from deepseek-php/feat/support-temperature-option
Browse files Browse the repository at this point in the history
feat support temperature option
  • Loading branch information
omaralalwi authored Jan 17, 2025
2 parents a9b127f + 0571779 commit 38e7981
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
build
vendor
tests/TestSupport/temp
tests/temp
composer.lock
phpunit.xml
.env
.phpunit.cache/
.phpunit.result.cache
.phpunit.cache/test-results
.php-cs-fixer.cache
phpstan.neon
tests/Support/temp/
.idea/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ $response = DeepseekClient::build($apiKey, 'https://api.deepseek.com/v2', 500)
->query('System setup query', 'system')
->query('User input message', 'user')
->withModel(Models::CODER->value)
->setTemperature(1.5)
->run();

echo 'API Response:'.$response;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"role": "creator"
}
],
"version": "1.0.0.0",
"version": "1.0.2",
"require": {
"php": "^8.1.0",
"php-http/discovery": "^1.20.0",
Expand Down
9 changes: 9 additions & 0 deletions src/DeepseekClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class DeepseekClient implements DeepseekClientContract
*/
protected bool $stream;

protected int $temperature;

/**
* Initialize the DeepseekClient with a PSR-compliant HTTP client.
*
Expand All @@ -61,6 +63,7 @@ public function run(): string
QueryFlags::MESSAGES->value => $this->queries,
QueryFlags::MODEL->value => $this->model,
QueryFlags::STREAM->value => $this->stream,
QueryFlags::TEMPERATURE->value => $this->temperature,
];
// Clear queries after sending
$this->queries = [];
Expand Down Expand Up @@ -123,6 +126,12 @@ public function withStream(bool $stream = true): self
return $this;
}

public function setTemperature(int $temperature): self
{
$this->temperature = $temperature;
return $this;
}

protected function buildQuery(string $content, ?string $role = null): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions src/Enums/Requests/QueryFlags.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ enum QueryFlags: string
case MESSAGES = 'messages';
case MODEL = 'model';
case STREAM = 'stream';
case TEMPERATURE = 'temperature';
}

0 comments on commit 38e7981

Please sign in to comment.