M3 Integration fixes

This commit is contained in:
Mark Gregory
2026-09-21 10:14:57 +01:00
parent 4af997c465
commit 6d60cbff84
5853 changed files with 79032 additions and 1825 deletions
+5 -7
View File
@@ -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(),