Files
pricebuddy/app/Services/Ai/ConfiguredStructuredAgent.php
Jeremy 8b02abb0aa feat: AI self-healing store config
Add AiConfigHealer to bootstrap or repair a store config via a
tool-using structured agent (fetch/css/regex tools, HealingContext,
shared StrategyExtractor).

- Run healing before the one-shot enhancer; AI-bootstrap a store config
  when product create would otherwise fail; StoreUrl validation defers
  to self-healing when enabled
- Per-feature AI provider resolution (AiFeature enum) and settings
- Per-store self-healing opt-out plus cooldown; log heal attempts and
  unusable proposals
- Heal with AI action with non-persisting preview/apply/discard in the
  store test modal; prompt switches to browser scraping when blocked
2026-06-09 15:07:40 +10:00

55 lines
1.5 KiB
PHP

<?php
namespace App\Services\Ai;
use Closure;
use Laravel\Ai\StructuredAnonymousAgent;
/**
* A structured anonymous agent that carries generation options (temperature,
* max tokens, top-p) sourced from application settings. The Laravel AI SDK
* resolves these via method_exists() in TextGenerationOptions::forAgent(),
* so defining them as methods is how anonymous-style agents set generation options.
*/
class ConfiguredStructuredAgent extends StructuredAnonymousAgent
{
/**
* The first four parameters mirror the parent constructor's order and types so the
* signature stays compatible with StructuredAnonymousAgent; the generation options
* are appended after. Construct with named arguments, e.g.
* `new ConfiguredStructuredAgent(instructions: ..., schema: ..., temperature: ...)`.
*/
public function __construct(
string $instructions,
iterable $messages = [],
iterable $tools = [],
?Closure $schema = null,
protected ?float $temperature = null,
protected ?int $maxTokens = null,
protected ?float $topP = null,
protected ?int $maxSteps = null,
) {
parent::__construct($instructions, $messages, $tools, $schema);
}
public function temperature(): ?float
{
return $this->temperature;
}
public function maxTokens(): ?int
{
return $this->maxTokens;
}
public function topP(): ?float
{
return $this->topP;
}
public function maxSteps(): ?int
{
return $this->maxSteps;
}
}