Skip to content

feat support temperature option #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}