M3 Integration fixes
This commit is contained in:
Regular → Executable
+5
-7
@@ -4,15 +4,13 @@ namespace Modules\ChatGPT\Services;
|
||||
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use RuntimeException;
|
||||
use Modules\ChatGPT\Exceptions\OpenAiFileException;
|
||||
|
||||
class OpenAiFileService
|
||||
{
|
||||
private const BASE_URL = 'https://api.openai.com/v1';
|
||||
|
||||
public function __construct(private readonly string $apiKey)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly string $apiKey) {}
|
||||
|
||||
/**
|
||||
* List all OpenAI API files visible to the configured API key.
|
||||
@@ -35,7 +33,7 @@ class OpenAiFileService
|
||||
->get(self::BASE_URL . '/files', $query);
|
||||
|
||||
if ($response->failed()) {
|
||||
throw new RuntimeException('OpenAI file list request failed: ' . $response->body());
|
||||
throw new OpenAiFileException('OpenAI file list request failed: ' . $response->body());
|
||||
}
|
||||
|
||||
$payload = $response->json();
|
||||
@@ -65,7 +63,7 @@ class OpenAiFileService
|
||||
->delete(self::BASE_URL . '/files/' . rawurlencode($fileId));
|
||||
|
||||
if ($response->failed()) {
|
||||
throw new RuntimeException("OpenAI file delete request failed for {$fileId}: " . $response->body());
|
||||
throw new OpenAiFileException("OpenAI file delete request failed for {$fileId}: " . $response->body());
|
||||
}
|
||||
|
||||
return $response->json() ?? [];
|
||||
@@ -92,7 +90,7 @@ class OpenAiFileService
|
||||
try {
|
||||
$this->deleteFile($fileId);
|
||||
$deleted++;
|
||||
} catch (RuntimeException $exception) {
|
||||
} catch (OpenAiFileException $exception) {
|
||||
$failures[] = [
|
||||
'file_id' => $fileId,
|
||||
'error' => $exception->getMessage(),
|
||||
|
||||
Reference in New Issue
Block a user