diff --git a/README-AR.md b/README-AR.md index 10905a9..8e9ad5a 100644 --- a/README-AR.md +++ b/README-AR.md @@ -100,6 +100,7 @@ $response = $client ->withModel(Models::CODER->value) ->withStream() ->withTemperature(1.2) + ->setMaxTokens(8192) ->query('Explain quantum computing in simple terms') ->run(); diff --git a/README-CN.md b/README-CN.md index ebd7e19..b93bb99 100644 --- a/README-CN.md +++ b/README-CN.md @@ -99,6 +99,7 @@ $response = $client ->withModel(Models::CODER->value) ->withStream() ->withTemperature(1.2) + ->setMaxTokens(8192) ->query('Explain quantum computing in simple terms') ->run(); diff --git a/README.md b/README.md index c70c40f..6ec9b7e 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ $response = $client ->withModel(Models::CODER->value) ->withStream() ->setTemperature(1.2) + ->setMaxTokens(8192) ->query('Explain quantum computing in simple terms') ->run(); diff --git a/composer.json b/composer.json index 5f03fd6..e4a48f2 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "role": "creator" } ], - "version": "2.0.4", + "version": "2.0.5", "require": { "php": "^8.1.0", "nyholm/psr7": "^1.8", diff --git a/src/DeepSeekClient.php b/src/DeepSeekClient.php index 93c989d..c44d0cd 100644 --- a/src/DeepSeekClient.php +++ b/src/DeepSeekClient.php @@ -49,6 +49,7 @@ class DeepSeekClient implements ClientContract protected bool $stream; protected float $temperature; + protected int $maxTokens; /** * response result contract @@ -79,6 +80,7 @@ public function __construct(ClientInterface $httpClient) $this->requestMethod = 'POST'; $this->endpointSuffixes = EndpointSuffixes::CHAT->value; $this->temperature = (float) TemperatureValues::GENERAL_CONVERSATION->value; + $this->maxTokens = (int) TemperatureValues::MAX_TOKENS->value; $this->tools = null; } @@ -89,6 +91,7 @@ public function run(): string QueryFlags::MODEL->value => $this->model, QueryFlags::STREAM->value => $this->stream, QueryFlags::TEMPERATURE->value => $this->temperature, + QueryFlags::MAX_TOKENS->value => $this->maxTokens, QueryFlags::TOOLS->value => $this->tools, ]; @@ -183,6 +186,12 @@ public function setTemperature(float $temperature): self return $this; } + public function setMaxTokens(int $maxTokens): self + { + $this->maxTokens = $maxTokens; + return $this; + } + public function buildQuery(string $content, ?string $role = null): array { return [ diff --git a/src/Enums/Configs/TemperatureValues.php b/src/Enums/Configs/TemperatureValues.php index 12c21b1..b9b9a93 100644 --- a/src/Enums/Configs/TemperatureValues.php +++ b/src/Enums/Configs/TemperatureValues.php @@ -12,4 +12,5 @@ enum TemperatureValues: string case TRANSLATION = "1.4"; case CREATIVE_WRITING = "1.5"; case POETRY = "1.6"; + case MAX_TOKENS = "4096"; } diff --git a/src/Enums/Requests/QueryFlags.php b/src/Enums/Requests/QueryFlags.php index 0e2b49a..2b4b557 100644 --- a/src/Enums/Requests/QueryFlags.php +++ b/src/Enums/Requests/QueryFlags.php @@ -8,5 +8,6 @@ enum QueryFlags: string case MODEL = 'model'; case STREAM = 'stream'; case TEMPERATURE = 'temperature'; + case MAX_TOKENS = 'max_tokens'; case TOOLS = 'tools'; }