Skip to content

Commit d96a5ed

Browse files
committed
Fix class Erdum\Exception not found
1 parent 1a7bff4 commit d96a5ed

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/OpenAIAssistant.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function create_assistant($name, $instructions, $tools)
3535
));
3636

3737
if (empty($response['id'])) {
38-
throw new Exception('Unable to create a assistant');
38+
throw new \Exception('Unable to create a assistant');
3939
}
4040
$this->assistant_id = $response['id'];
4141
return $response['id'];
@@ -44,7 +44,7 @@ public function create_assistant($name, $instructions, $tools)
4444
public function modify_assistant($name, $instructions, $tools)
4545
{
4646
if (!$this->assistant_id) {
47-
throw new Exception(
47+
throw new \Exception(
4848
'You need to provide a assistant_id or create an assistant.'
4949
);
5050
}
@@ -57,7 +57,7 @@ public function modify_assistant($name, $instructions, $tools)
5757
));
5858

5959
if (empty($response['id'])) {
60-
throw new Exception('Unable to create a assistant');
60+
throw new \Exception('Unable to create a assistant');
6161
}
6262
$this->assistant_id = $response['id'];
6363
return $response['id'];
@@ -85,7 +85,7 @@ public function create_thread($content, $role = 'user')
8585
));
8686

8787
if (empty($response['id'])) {
88-
throw new Exception('Unable to create a thread');
88+
throw new \Exception('Unable to create a thread');
8989
}
9090
return $response['id'];
9191
}
@@ -95,7 +95,7 @@ public function get_thread($thread_id)
9595
$response = $this->send_get_request("/threads/{$thread_id}");
9696

9797
if (empty($response['id'])) {
98-
throw new Exception('Unable to retrive a thread');
98+
throw new \Exception('Unable to retrive a thread');
9999
}
100100
return $response;
101101
}
@@ -128,7 +128,7 @@ public function add_message($thread_id, $content, $role = 'user')
128128
);
129129

130130
if (empty($response['id'])) {
131-
throw new Exception('Unable to create a message');
131+
throw new \Exception('Unable to create a message');
132132
}
133133
return $response['id'];
134134
}
@@ -138,7 +138,7 @@ public function get_message($thread_id, $message_id)
138138
$response = $this->send_get_request("/threads/{$thread_id}/messages/{$message_id}");
139139

140140
if (empty($response['id'])) {
141-
throw new Exception('Unable to retrive a message');
141+
throw new \Exception('Unable to retrive a message');
142142
}
143143
return $response;
144144
}
@@ -218,7 +218,7 @@ public function execute_tools(
218218
'output' => json_encode($data)
219219
));
220220
} else {
221-
throw new Exception("Failed to execute tool: The $method_name you provided is not callable");
221+
throw new \Exception("Failed to execute tool: The $method_name you provided is not callable");
222222
}
223223
}
224224
$this->has_tool_calls = false;
@@ -233,7 +233,7 @@ public function submit_tool_outputs($thread_id, $execution_id, $outputs)
233233
);
234234

235235
if (empty($response['id'])) {
236-
throw new Exception('Unable to submit tool outputs');
236+
throw new \Exception('Unable to submit tool outputs');
237237
}
238238

239239
do {
@@ -260,12 +260,12 @@ private function execute_request($ch)
260260
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
261261

262262
if ($errno = curl_errno($ch)) {
263-
throw new Exception(
263+
throw new \Exception(
264264
'CURL failed to call OpenAI API: ' . curl_error($ch),
265265
$errno
266266
);
267267
} else if ($http_code != 200) {
268-
throw new Exception(
268+
throw new \Exception(
269269
"OpenAI API Returned Unexpected HTTP code $http_code"
270270
);
271271
}
@@ -316,7 +316,7 @@ private function create_run($thread_id, $assistant_id)
316316
);
317317

318318
if (empty($response['id'])) {
319-
throw new Exception('Unable to create a run');
319+
throw new \Exception('Unable to create a run');
320320
}
321321
return $response['id'];
322322
}
@@ -326,7 +326,7 @@ private function get_run($thread_id, $run_id)
326326
$response = $this->send_get_request("/threads/{$thread_id}/runs/{$run_id}");
327327

328328
if (empty($response['id'])) {
329-
throw new Exception('Unable to create a run');
329+
throw new \Exception('Unable to create a run');
330330
}
331331
return $response;
332332
}

0 commit comments

Comments
 (0)