*/ public static array $answers = []; /** @var list */ public static array $requests = []; /** * @param array $config */ public function __construct(private readonly string $provider, private readonly array $config) {} /** * Point both tasks at this driver and queue up its answers. * * @param list $answers */ public static function use(array $answers): void { self::$answers = $answers; self::$requests = []; config([ 'ai.providers.scripted' => ['driver' => self::class], 'ai.tasks.generate.provider' => 'scripted', 'ai.tasks.edit.provider' => 'scripted', ]); } public function complete(AiRequest $request): AiResponse { self::$requests[] = $request; $answer = array_shift(self::$answers) ?? throw new AiException('No scripted answer left.'); if ($answer instanceof AiException) { throw $answer; } return new AiResponse($answer, $this->provider, $request->model, 100, 200); } }