13
13
use DeepSeek \Enums \Requests \QueryFlags ;
14
14
use DeepSeek \Enums \Configs \TemperatureValues ;
15
15
use DeepSeek \Traits \Resources \{HasChat , HasCoder };
16
+ use DeepSeek \Traits \Client \HasToolsFunctionCalling ;
16
17
17
18
class DeepSeekClient implements ClientContract
18
19
{
19
20
use HasChat, HasCoder;
21
+ use HasToolsFunctionCalling;
20
22
21
23
/**
22
24
* PSR-18 HTTP client for making requests.
@@ -58,6 +60,12 @@ class DeepSeekClient implements ClientContract
58
60
59
61
protected ?string $ endpointSuffixes ;
60
62
63
+ /**
64
+ * Array of tools for using function calling.
65
+ * @var array|null $tools
66
+ */
67
+ protected ?array $ tools ;
68
+
61
69
/**
62
70
* Initialize the DeepSeekClient with a PSR-compliant HTTP client.
63
71
*
@@ -71,6 +79,7 @@ public function __construct(ClientInterface $httpClient)
71
79
$ this ->requestMethod = 'POST ' ;
72
80
$ this ->endpointSuffixes = EndpointSuffixes::CHAT ->value ;
73
81
$ this ->temperature = (float ) TemperatureValues::GENERAL_CONVERSATION ->value ;
82
+ $ this ->tools = null ;
74
83
}
75
84
76
85
public function run (): string
@@ -80,9 +89,9 @@ public function run(): string
80
89
QueryFlags::MODEL ->value => $ this ->model ,
81
90
QueryFlags::STREAM ->value => $ this ->stream ,
82
91
QueryFlags::TEMPERATURE ->value => $ this ->temperature ,
92
+ QueryFlags::TOOLS ->value => $ this ->tools ,
83
93
];
84
- // Clear queries after sending
85
- $ this ->queries = [];
94
+
86
95
$ this ->setResult ((new Resource ($ this ->httpClient , $ this ->endpointSuffixes ))->sendRequest ($ requestData , $ this ->requestMethod ));
87
96
return $ this ->getResult ()->getContent ();
88
97
}
@@ -120,6 +129,17 @@ public function query(string $content, ?string $role = "user"): self
120
129
$ this ->queries [] = $ this ->buildQuery ($ content , $ role );
121
130
return $ this ;
122
131
}
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
+ }
123
143
124
144
/**
125
145
* get list of available models .
@@ -173,7 +193,7 @@ public function buildQuery(string $content, ?string $role = null): array
173
193
174
194
/**
175
195
* set result model
176
- * @param \DeepseekPhp \Contracts\Models\ResultContract $result
196
+ * @param \DeepSeek \Contracts\Models\ResultContract $result
177
197
* @return self The current instance for method chaining.
178
198
*/
179
199
public function setResult (ResultContract $ result )
0 commit comments