AiProviderDriver: one generic interface (generate(prompt, options) ->
AiGenerationResult) rather than per-capability interfaces, since text
(OpenAI chat completions), image (StabilityAI stable-image), and
speech (ElevenLabs TTS) generation all reduce to prompt-in/content-out.
Drivers throw AiGenerationException on failure; AiProviderManager
resolves the right driver from an AiProvider record's `provider`
column and guards on is_active. Real request/response shapes per each
provider's API, verified with Http::fake() — no live API keys
available yet to smoke test against the real services.
AssetStorage: stores generated content under
video-projects/{id}/{type}/v{n}.{ext}, versioned per (project, type[,
step]) slot so retries don't clobber earlier output, plus
contents/url/delete and pruneOldVersions for cleanup.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\AiProviders;
|
||||
|
||||
use App\Models\AiProvider;
|
||||
|
||||
interface AiProviderDriver
|
||||
{
|
||||
/**
|
||||
* Generate content from a prompt. What "content" means depends on the
|
||||
* provider — text for a text generator, image bytes for an image
|
||||
* generator, audio bytes for a speech synthesizer. $options overrides
|
||||
* $provider->config for this call only (e.g. model, voice_id).
|
||||
*
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @throws AiGenerationException on any failure (bad credentials,
|
||||
* unreachable API, rejected prompt, unexpected response shape).
|
||||
*/
|
||||
public function generate(AiProvider $provider, string $prompt, array $options = []): AiGenerationResult;
|
||||
}
|
||||
Reference in New Issue
Block a user