index-main/site/plugins/kirby-seo/classes/Ai/Driver.php
isUnknown 04a14a7f1f chore: update kirby-seo plugin to v2.0.0-alpha.12
Update plugin from v1.1.2 to v2.0.0-alpha.12 for Kirby 5 compatibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 16:23:23 +01:00

40 lines
1,001 B
PHP

<?php
namespace tobimori\Seo\Ai;
use Generator;
use Kirby\Exception\InvalidArgumentException;
use tobimori\Seo\Seo;
abstract class Driver
{
public function __construct(protected string $providerId)
{
}
/**
* Streams a response for the given prompt and optional context data.
*
* @param string $prompt User prompt (e.g. Tasks).
* @param string|null $model Model to use.
*
* @return Generator<int, Chunk, mixed, void>
*/
abstract public function stream(string $prompt, string|null $model = null): Generator;
/**
* Returns a configuration value or throws when required.
*/
protected function config(string $key, mixed $default = null, bool $required = false): mixed
{
$value = Seo::option("ai.providers.{$this->providerId}.config.{$key}", $default);
if ($required === true && ($value === null || $value === '')) {
throw new InvalidArgumentException(
"Missing required \"{$key}\" configuration for driver " . static::class . '.'
);
}
return $value;
}
}