8000 update: add tool property and reset query function. · deepseek-php/deepseek-php-client@ade67b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit ade67b3

Browse files
committed
update: add tool property and reset query function.
1 parent 21b5dbc commit ade67b3

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/DeepSeekClient.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
use DeepSeek\Enums\Requests\QueryFlags;
1414
use DeepSeek\Enums\Configs\TemperatureValues;
1515
use DeepSeek\Traits\Resources\{HasChat, HasCoder};
16+
use DeepSeek\Traits\Client\HasToolsFunctionCalling;
1617

1718
class DeepSeekClient implements ClientContract
1819
{
1920
use HasChat, HasCoder;
21+
use HasToolsFunctionCalling;
2022

2123
/**
2224
* PSR-18 HTTP client for making requests.
@@ -58,6 +60,12 @@ class DeepSeekClient implements ClientContract
5860

5961
protected ?string $endpointSuffixes;
6062

63+
/**
64+
* Array of tools for using function calling.
65+
* @var array|null $tools
66+
*/
67+
protected ?array $tools;
68+
6169
/**
6270
* Initialize the DeepSeekClient with a PSR-compliant HTTP client.
6371
*
@@ -71,6 +79,7 @@ public function __construct(ClientInterface $httpClient)
7179
$this->requestMethod = 'POST';
7280
$this->endpointSuffixes = EndpointSuffixes::CHAT->value;
7381
$this->temperature = (float) TemperatureValues::GENERAL_CONVERSATION->value;
82+
$this->tools = null;
7483
}
7584

7685
public function run(): string
@@ -80,9 +89,9 @@ public function run(): string
8089
QueryFlags::MODEL->value => $this->model,
8190
QueryFlags::STREAM->value => $this->stream,
8291
QueryFlags::TEMPERATURE->value => $this->temperature,
92+
QueryFlags::TOOLS->value => $this->tools,
8393
];
84-
// Clear queries after sending
85-
$this->queries = [];
94+
8695
$this->setResult((new Resource($this->httpClient, $this->endpointSuffixes))->sendRequest($requestData, $this->requestMethod));
8796
return $this->getResult()->getContent();
8897
}
@@ -120,6 +129,17 @@ public function query(string $content, ?string $role = "user"): self
120129
$this->queries[] = $this->buildQuery($content, $role);
121130
return $this;
122131
}
132+
133+
/**
134+
* Reset a queries list to empty.
135+
*
136+
* @return self The current instance for method chaining.
137+
*/
138+
public function resetQuery()
139+
{
140+
$this->query = [];
141+
return $this;
142+
}
123143

124144
/**
125145
* get list of available models .
@@ -173,7 +193,7 @@ public function buildQuery(string $content, ?string $role = null): array
173193

174194
/**
175195
* set result model
176-
* @param \DeepseekPhp\Contracts\Models\ResultContract $result
196+
* @param \DeepSeek\Contracts\Models\ResultContract $result
177197
* @return self The current instance for method chaining.
178198
*/
179199
public function setResult(ResultContract $result)

0 commit comments

Comments
 (0)
0