File size: 5,293 Bytes
afe04f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
class CustomSidebar extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    display: flex;
                    flex-direction: column;
                    padding: 1.5rem;
                    gap: 2rem;
                    overflow-y: auto;
                    background: rgba(30, 41, 59, 0.5);
                }
                h3 {
                    font-size: 0.875rem;
                    text-transform: uppercase;
                    letter-spacing: 0.05em;
                    color: #94a3b8;
                    margin-bottom: 1rem;
                    display: flex;
                    align-items: center;
                    gap: 0.5rem;
                }
                .control-group {
                    margin-bottom: 1.5rem;
                }
                label {
                    display: block;
                    font-size: 0.75rem;
                    margin-bottom: 0.5rem;
                    color: #cbd5e1;
                }
                input[type="text"], textarea, select {
                    width: 100%;
                    background: #0f172a;
                    border: 1px solid #334155;
                    color: white;
                    padding: 0.5rem;
                    border-radius: 0.375rem;
                    font-size: 0.875rem;
                    margin-bottom: 0.5rem;
                    box-sizing: border-box;
                }
                input[type="text"]:focus, textarea:focus, select:focus {
                    outline: none;
                    border-color: #6366f1;
                    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
                }
                input[type="range"] {
                    width: 100%;
                    accent-color: #6366f1;
                }
                .range-value {
                    font-size: 0.75rem;
                    float: right;
                    color: #6366f1;
                }
                button.btn-block {
                    width: 100%;
                    padding: 0.5rem;
                    background: #334155;
                    color: white;
                    border: none;
                    border-radius: 0.375rem;
                    cursor: pointer;
                    transition: all 0.2s;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    gap: 0.5rem;
                }
                button.btn-block:hover {
                    background: #475569;
                }
                button.btn-danger {
                    background: rgba(239, 68, 68, 0.1);
                    color: #f87171;
                    border: 1px solid rgba(239, 68, 68, 0.2);
                }
                button.btn-danger:hover {
                    background: rgba(239, 68, 68, 0.2);
                }
            </style>

            <div class="control-group">
                <h3><i data-feather="database"></i> Session</h3>
                <label>Session ID</label>
                <input type="text" id="session-id" value="session_001">
            </div>

            <div class="control-group">
                <h3><i data-feather="terminal"></i> Agent Settings</h3>
                <label>System Prompt</label>
                <textarea id="system-prompt" rows="3">You are an advanced AI agent. Use tools when needed.</textarea>
                
                <label>Max Tokens <span class="range-value" id="tokens-val">512</span></label>
                <input type="range" min="128" max="2048" value="512" id="max-tokens">

                <label>Temperature <span class="range-value" id="temp-val">0.7</span></label>
                <input type="range" min="0" max="1" step="0.1" value="0.7" id="temperature">
                
                <label>Top-p <span class="range-value" id="topp-val">0.95</span></label>
                <input type="range" min="0" max="1" step="0.05" value="0.95" id="top-p">
            </div>

            <div class="control-group" style="margin-top: auto;">
                <button id="clear-mem" class="btn-block btn-danger">
                    <i data-feather="trash-2"></i> Clear Memory
                </button>
            </div>
        `;

        // Event Listeners for Range Sliders
        this.shadowRoot.getElementById('max-tokens').addEventListener('input', (e) => {
            this.shadowRoot.getElementById('tokens-val').textContent = e.target.value;
        });
        this.shadowRoot.getElementById('temperature').addEventListener('input', (e) => {
            this.shadowRoot.getElementById('temp-val').textContent = e.target.value;
        });
        this.shadowRoot.getElementById('top-p').addEventListener('input', (e) => {
            this.shadowRoot.getElementById('topp-val').textContent = e.target.value;
        });

        // Clear Memory Logic
        this.shadowRoot.getElementById('clear-mem').addEventListener('click', () => {
            if(window.MemoryDB) window.MemoryDB.clear();
        });

        // Replace Icons
        feather.replace();
    }
}
customElements.define('custom-sidebar', CustomSidebar);