File size: 5,033 Bytes
13d012b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<!--
  GPT-2 Text Generation UI
  ========================
  Single-page interface for interacting with the Flask /generate endpoint.
  All logic lives in static/app.js; styling in static/style.css.

  Design language: Hugging Face-inspired β€” deep indigo background, purple-to-blue
  gradients, Space Grotesk display type, monospace output pane.
-->
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>GPT-2 Playground</title>
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
  <link rel="stylesheet" href="static/style.css" />
</head>
<body>

  <header class="site-header">
    <div class="logo">
      <svg width="28" height="28" viewBox="0 0 28 28" fill="none" aria-hidden="true">
        <rect width="28" height="28" rx="8" fill="url(#logoGrad)"/>
        <path d="M8 20 L14 8 L20 20" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
        <path d="M10 16 H18" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
        <defs>
          <linearGradient id="logoGrad" x1="0" y1="0" x2="28" y2="28">
            <stop offset="0%" stop-color="#7C3AED"/>
            <stop offset="100%" stop-color="#2563EB"/>
          </linearGradient>
        </defs>
      </svg>
      <span>LLara Playground</span>
    </div>
    <div class="model-badge">gpt2 Β· HF Transformers</div>
  </header>

  <main class="main-layout">

    <!-- ── Left column: controls ── -->
    <aside class="controls-panel">
      <h2 class="panel-title">Parameters</h2>

      <div class="control-group">
        <label for="maxTokens">Max new tokens <span class="value-display" id="maxTokensVal">200</span></label>
        <input type="range" id="maxTokens" min="20" max="500" step="10" value="200" />
      </div>

      <div class="control-group">
        <label for="temperature">Temperature <span class="value-display" id="temperatureVal">0.90</span></label>
        <input type="range" id="temperature" min="0.1" max="2.0" step="0.05" value="0.90" />
      </div>

      <div class="control-group">
        <label for="topP">Top-p <span class="value-display" id="topPVal">0.95</span></label>
        <input type="range" id="topP" min="0.1" max="1.0" step="0.05" value="0.95" />
      </div>

      <div class="control-group">
        <label for="repPenalty">Repetition penalty <span class="value-display" id="repPenaltyVal">1.20</span></label>
        <input type="range" id="repPenalty" min="1.0" max="2.0" step="0.05" value="1.20" />
      </div>

      <div class="param-explainer">
        <p><strong>Temperature</strong> β€” randomness. Higher = more creative, lower = more focused.</p>
        <p><strong>Top-p</strong> β€” nucleus sampling. Keeps only the top cumulative probability mass.</p>
        <p><strong>Repetition penalty</strong> β€” discourages repeated phrases.</p>
      </div>
    </aside>

    <!-- ── Right column: prompt + output ── -->
    <section class="generation-panel">

      <div class="prompt-area">
        <label for="promptInput" class="sr-only">Prompt</label>
        <textarea
          id="promptInput"
          placeholder="Enter your prompt here β€” e.g. 'The future of artificial intelligence is'"
          rows="5"
          spellcheck="false"
        ></textarea>
        <div class="prompt-footer">
          <span class="char-count" id="charCount">0 chars</span>
          <button class="btn-generate" id="generateBtn">
            <span class="btn-label">Generate</span>
            <span class="btn-spinner" aria-hidden="true"></span>
          </button>
        </div>
      </div>

      <div class="output-container" id="outputContainer" aria-live="polite">
        <div class="output-header">
          <span class="output-label">Output</span>
          <button class="btn-copy" id="copyBtn" title="Copy output" aria-label="Copy output" disabled>
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
              <rect x="9" y="9" width="13" height="13" rx="2"/>
              <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
            </svg>
            Copy
          </button>
        </div>
        <div class="output-body">
          <div class="output-prompt" id="outputPrompt"></div>
          <div class="output-generated" id="outputGenerated">
            <span class="placeholder-text">Generated text will appear here…</span>
          </div>
        </div>
      </div>

      <div class="error-banner" id="errorBanner" role="alert" hidden></div>

    </section>
  </main>

  <script src="static/app.js"></script>
</body>
</html>>