@extends('layouts.admin') @section('title', __('Chatbot logs')) @section('content')

{{ __('Chatbot logs') }}

{{ __('Stored chat requests and AI replies from :path.', ['path' => 'storage/chatbot/chats.json']) }}

@if($logs->isEmpty())
{{ __('No chat logs yet.') }}
@else
@foreach($logs as $row) @php $status = $row['status'] ?? ''; $isOk = $status === 'success'; $sourceLinks = []; $rawSources = $row['sources'] ?? []; if (is_array($rawSources)) { foreach ($rawSources as $item) { if (is_array($item) && ! empty($item['url']) && is_string($item['url'])) { $sourceLinks[] = $item; } } } $attempts = is_array($row['attempts'] ?? null) ? $row['attempts'] : []; @endphp @endforeach
{{ __('When') }} {{ __('Status') }} {{ __('User message') }} {{ __('AI response') }} {{ __('Provider') }} {{ __('Key') }} {{ __('Sources') }} {{ __('Model') }} {{ __('Cache') }} {{ __('Attempts') }} {{ __('Error') }}
{{ $row['created_at'] ?? '—' }} @if($isOk) {{ __('Success') }} @else {{ __('Failed') }} @endif
{{ \Illuminate\Support\Str::limit($row['user_message'] ?? '', 80) }}
{{ $row['user_message'] ?? '' }}
{{ \Illuminate\Support\Str::limit($row['ai_response'] ?? '', 80) }}
{{ $row['ai_response'] ?? '' }}
{{ $row['provider_name'] ?? $row['provider_used'] ?? '—' }}
@if(!empty($row['provider_used']))
{{ $row['provider_used'] }}
@endif
{{ $row['key_used'] ?? '—' }} @if(count($sourceLinks) > 0) @else — @endif {{ $row['model_used'] ?: '—' }} @if(!empty($row['cache_hit'])) {{ __('Hit') }} @else {{ __('Miss') }} @endif @if(count($attempts) > 0)
{{ __('View attempts') }} ({{ count($attempts) }})
@foreach($attempts as $attempt)
{{ $attempt['provider_name'] ?? $attempt['provider'] ?? '—' }} / {{ $attempt['api_key'] ?? '—' }}
{{ __('Status') }}: {{ $attempt['status'] ?? '—' }} @if(!empty($attempt['http_status'])) (HTTP {{ $attempt['http_status'] }}) @endif
@if(!empty($attempt['message']))
{{ $attempt['message'] }}
@endif
@endforeach
@else — @endif
@if(!empty($row['error'])) {{ $row['error'] }} @else — @endif
@endif @endsection