Fix model name to gemini-1.5-flash v2.2.3

This commit is contained in:
Enes Yakıştır
2026-05-13 12:46:26 +03:00
parent 40dc04d328
commit 3a19c1c534
7 changed files with 149 additions and 9 deletions
+13 -4
View File
@@ -11,15 +11,23 @@ class GeminiFixer
public function __construct(private readonly ?string $apiKey)
{
if ($this->apiKey && class_exists(Gemini::class)) {
$this->client = Gemini::client($this->apiKey);
if ($this->apiKey) {
try {
$this->client = \Gemini::client($this->apiKey);
} catch (\Throwable) {
$this->client = null;
}
}
}
public function suggestFix(Violation $violation): ?string
{
if (!$this->apiKey) {
return "Hata: GEMINI_API_KEY bulunamadı.";
}
if (!$this->client) {
return null;
return "Hata: Gemini istemcisi başlatılamadı. Kütüphane eksik olabilir.";
}
$prompt = <<<PROMPT
@@ -37,7 +45,8 @@ If it's about ARIA roles, add the correct ones.
PROMPT;
try {
$result = $this->client->generativeModel('gemini-2.5-flash')->generateContent($prompt);
// Stable model: gemini-1.5-flash
$result = $this->client->generativeModel('gemini-1.5-flash')->generateContent($prompt);
$suggestion = trim($result->text());
// Clean up if AI included markdown blocks anyway
+1
View File
@@ -83,6 +83,7 @@ class ScanCommand extends Command
$io->write(" <fg=gray>AI Fix Suggestion:</> ");
$suggestion = $fixer->suggestFix($violation);
if ($suggestion) {
$violation->fixSuggestion = $suggestion;
$io->writeln("<fg=green>" . htmlspecialchars($suggestion) . "</>");
} else {
$io->writeln("<fg=red>Could not generate suggestion (check API key)</>");
+24 -4
View File
@@ -4,10 +4,10 @@ namespace YakNet\AccessibilityConsole\Core;
class RuleEngine
{
/** @var AbstractRule[] */
/** @var array */
private array $rules = [];
public function addRule(AbstractRule $rule): void
public function addRule(mixed $rule): void
{
$this->rules[] = $rule;
}
@@ -19,8 +19,28 @@ class RuleEngine
{
$allViolations = [];
foreach ($this->rules as $rule) {
$violations = $rule->check($doc);
$allViolations = array_merge($allViolations, $violations);
if (method_exists($rule, 'check')) {
// Determine if it's a document-level rule or element-level rule
$reflection = new \ReflectionMethod($rule, 'check');
$params = $reflection->getParameters();
if (isset($params[0]) && $params[0]->getType() && $params[0]->getType()->getName() === 'DOMDocument') {
// Document-level rule (Core\AbstractRule style)
$violations = $rule->check($doc);
$allViolations = array_merge($allViolations, $violations);
} else {
// Element-level rule (Rules\RuleInterface style)
// We need to iterate over all elements
$xpath = new \DOMXPath($doc);
$elements = $xpath->query('//*');
foreach ($elements as $element) {
$violation = $rule->check($element);
if ($violation) {
$allViolations[] = $violation;
}
}
}
}
}
return $allViolations;
}
+5
View File
@@ -11,6 +11,11 @@ class Scanner
}
}
public function addRule(mixed $rule): void
{
$this->engine->addRule($rule);
}
/**
* Scan HTML content for accessibility violations.
*
+1 -1
View File
@@ -2,7 +2,7 @@
namespace YakNet\AccessibilityConsole\Core;
readonly class Violation
class Violation
{
public function __construct(
public string $ruleId,
+4
View File
@@ -22,6 +22,7 @@ class HtmlDashboardReporter
<td><span class='badge'>{$v->ruleId}</span></td>
<td>{$v->message}</td>
<td><pre><code>" . htmlspecialchars($v->htmlSnippet) . "</code></pre></td>
<td>" . ($v->fixSuggestion ? "<pre class='ai-fix'><code>" . htmlspecialchars($v->fixSuggestion) . "</code></pre>" : "<span class='text-muted'>Manual fix required</span>") . "</td>
<td>" . ($v->location ? "{$v->location['file']}:{$v->location['line']}" : 'N/A') . "</td>
</tr>";
}
@@ -43,8 +44,10 @@ class HtmlDashboardReporter
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #eee; }
th { background: #f8f9fa; }
pre { background: #272822; color: #f8f8f2; padding: 10px; border-radius: 4px; overflow-x: auto; font-size: 12px; }
.ai-fix { border-left: 4px solid #2ecc71; background: #1e1e1e; }
.badge { background: #34495e; color: white; padding: 4px 8px; border-radius: 4px; font-size: 11px; }
.severity-error { background: #fff5f5; }
.text-muted { color: #95a5a6; font-size: 0.9em; font-style: italic; }
</style>
</head>
<body>
@@ -69,6 +72,7 @@ class HtmlDashboardReporter
<th>Rule ID</th>
<th>Issue</th>
<th>Code Snippet</th>
<th>AI Recommendation</th>
<th>Source Location</th>
</tr>
</thead>