diff --git a/app/Domains/Ai/Services/AiService.php b/app/Domains/Ai/Services/AiService.php index 4939272..bb8c3ec 100644 --- a/app/Domains/Ai/Services/AiService.php +++ b/app/Domains/Ai/Services/AiService.php @@ -19,7 +19,7 @@ class AiService 'Content-Type' => 'application/json', ])->post('https://api.openai.com/v1/chat/completions', [ 'model' => $model, - 'max_tokens' => 512, + 'max_tokens' => 800, 'messages' => [['role' => 'user', 'content' => $prompt]], ]); diff --git a/app/Livewire/Pages/Ai/Insights.php b/app/Livewire/Pages/Ai/Insights.php index 39a87b6..4e8d7fd 100644 --- a/app/Livewire/Pages/Ai/Insights.php +++ b/app/Livewire/Pages/Ai/Insights.php @@ -45,9 +45,31 @@ class Insights extends Component return; } - $summary = $topLinks->map(fn ($l) => "{$l->slug}: {$l->clicks_count} clicks → {$l->target_url}")->implode("\n"); + $locale = auth()->user()?->locale ?? 'en'; + $langMap = ['de' => 'German', 'en' => 'English', 'fr' => 'French', 'es' => 'Spanish', 'it' => 'Italian', 'pt' => 'Portuguese']; + $language = $langMap[$locale] ?? 'English'; - $prompt = "You are a marketing analyst. Analyze these link performance stats and provide 3-5 actionable insights:\n\n{$summary}\n\nBe concise and specific."; + $totalClicks = $topLinks->sum('clicks_count'); + $linkCount = $topLinks->count(); + $summary = $topLinks->map(fn ($l) => "- {$l->slug} ({$l->clicks_count} clicks) → {$l->target_url}")->implode("\n"); + + $prompt = <<name} +Total links analysed: {$linkCount} | Total clicks: {$totalClicks} + +Top links: +{$summary} + +Provide 3–4 short, specific insights: +- Which link types or destinations perform best and why +- Patterns across target domains (e.g. social, docs, pricing pages) +- What the low-click links have in common and how to improve them +- One concrete next action for this workspace + +No generic marketing advice. Base every insight on the data above. Be direct, no fluff. +PROMPT; $result = app(AiService::class)->complete($prompt); diff --git a/resources/views/components/ui/button.blade.php b/resources/views/components/ui/button.blade.php index 63fd6ed..915c44d 100644 --- a/resources/views/components/ui/button.blade.php +++ b/resources/views/components/ui/button.blade.php @@ -25,8 +25,8 @@ $cls = $base . ' ' . ($variants[$variant] ?? $variants['primary']); {{ $slot->isNotEmpty() ? $slot : $label }} @if($action) - - + +