<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LlamaBot Log Viewer</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://unpkg.com/htmx.org@1.9.6"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
    <link rel="stylesheet" href="{{ url_for('static', path='styles.css') }}">
</head>
<body>
    <div class="container mt-4">
        <h1 class="mb-4">LlamaBot Log Viewer</h1>
        <ul class="nav nav-tabs mb-4" id="myTab" role="tablist">
            <li class="nav-item" role="presentation">
                <button class="nav-link active" id="logs-tab" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="true">Logs</button>
            </li>
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="prompts-tab" data-bs-toggle="tab" data-bs-target="#prompts" type="button" role="tab" aria-controls="prompts" aria-selected="false">Compare Prompts</button>
            </li>
        </ul>
        <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active" id="logs" role="tabpanel" aria-labelledby="logs-tab">
                <div class="mb-3">
                    <input type="text" id="log-filter" class="form-control" placeholder="Filter logs...">
                </div>
                <div class="mb-3">
                    <select id="prompt-select" class="form-select" hx-get="/prompts" hx-trigger="load">
                        <option value="">Select a prompt</option>
                    </select>
                </div>
                <div class="mb-3">
                    <button id="export-logs" class="btn btn-primary">Export Logs as YAML</button>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="log-list">
                            <table class="table table-hover" hx-get="/logs" hx-trigger="load">
                                <tbody>
                                    <tr>
                                        <td colspan="6">Loading logs...</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div id="log-details" class="log-details">
                            Select a log to view details
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane fade" id="prompts" role="tabpanel" aria-labelledby="prompts-tab">
                <h2 class="mb-3">Compare Prompts</h2>
                <div class="mb-3">
                    <select id="function-name-select" class="form-select">
                        <option value="">Select a function name</option>
                    </select>
                </div>
                <div id="prompt-history-container"></div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="{{ url_for('static', path='script.js') }}"></script>
</body>
</html>
