sagar007 commited on
Commit
15967e4
·
verified ·
1 Parent(s): d692c8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -9
app.py CHANGED
@@ -66,9 +66,10 @@ body {
66
  color: #a0a0a0;
67
  }
68
  .header img {
69
- max-width: 200px;
70
  border-radius: 10px;
71
- margin-top: 15px;
 
72
  }
73
  .input-group, .output-group {
74
  background-color: #1a1a2e;
@@ -93,8 +94,39 @@ body {
93
  .generate-btn:hover {
94
  background-color: #c81e45 !important;
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  """
97
 
 
 
 
 
 
 
 
 
 
98
  # Gradio interface
99
  with gr.Blocks(css=css) as iface:
100
  gr.HTML(
@@ -107,16 +139,43 @@ with gr.Blocks(css=css) as iface:
107
  """
108
  )
109
 
110
- with gr.Group(elem_classes="input-group"):
111
- prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...", lines=5)
112
- max_length = gr.Slider(minimum=1, maximum=500, value=128, step=1, label="Max Length")
113
- temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
114
- generate_btn = gr.Button("Generate", elem_classes="generate-btn")
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
- with gr.Group(elem_classes="output-group"):
117
- output = gr.Textbox(label="Generated Text", lines=10)
118
 
119
  generate_btn.click(generate_text, inputs=[prompt, max_length, temperature], outputs=output)
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  # Launch the app
122
  iface.launch()
 
66
  color: #a0a0a0;
67
  }
68
  .header img {
69
+ max-width: 300px;
70
  border-radius: 10px;
71
+ margin: 15px auto;
72
+ display: block;
73
  }
74
  .input-group, .output-group {
75
  background-color: #1a1a2e;
 
94
  .generate-btn:hover {
95
  background-color: #c81e45 !important;
96
  }
97
+ .example-prompts {
98
+ background-color: #1f2b47;
99
+ padding: 15px;
100
+ border-radius: 10px;
101
+ margin-bottom: 20px;
102
+ }
103
+ .example-prompts h3 {
104
+ color: #e94560;
105
+ margin-bottom: 10px;
106
+ }
107
+ .example-prompts ul {
108
+ list-style-type: none;
109
+ padding-left: 0;
110
+ }
111
+ .example-prompts li {
112
+ margin-bottom: 5px;
113
+ cursor: pointer;
114
+ transition: color 0.3s ease;
115
+ }
116
+ .example-prompts li:hover {
117
+ color: #e94560;
118
+ }
119
  """
120
 
121
+ # Example prompts
122
+ example_prompts = [
123
+ "Write a Python function to find the n-th Fibonacci number.",
124
+ "Explain the concept of recursion in programming.",
125
+ "What are the key differences between Python and JavaScript?",
126
+ "Tell me a short story about a time-traveling robot.",
127
+ "Describe the process of photosynthesis in simple terms."
128
+ ]
129
+
130
  # Gradio interface
131
  with gr.Blocks(css=css) as iface:
132
  gr.HTML(
 
139
  """
140
  )
141
 
142
+ with gr.Group():
143
+ gr.HTML(
144
+ """
145
+ <div class="example-prompts">
146
+ <h3>Example Prompts:</h3>
147
+ <ul>
148
+ """ + "".join([f"<li>{prompt}</li>" for prompt in example_prompts]) + """
149
+ </ul>
150
+ </div>
151
+ """
152
+ )
153
+
154
+ with gr.Group(elem_classes="input-group"):
155
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...", lines=5)
156
+ max_length = gr.Slider(minimum=1, maximum=500, value=128, step=1, label="Max Length")
157
+ temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
158
+ generate_btn = gr.Button("Generate", elem_classes="generate-btn")
159
 
160
+ with gr.Group(elem_classes="output-group"):
161
+ output = gr.Textbox(label="Generated Text", lines=10)
162
 
163
  generate_btn.click(generate_text, inputs=[prompt, max_length, temperature], outputs=output)
164
 
165
+ # JavaScript to make example prompts clickable
166
+ gr.HTML(
167
+ """
168
+ <script>
169
+ document.addEventListener('DOMContentLoaded', (event) => {
170
+ document.querySelectorAll('.example-prompts li').forEach(item => {
171
+ item.addEventListener('click', event => {
172
+ document.querySelector('textarea[data-testid="textbox"]').value = event.target.textContent;
173
+ });
174
+ });
175
+ });
176
+ </script>
177
+ """
178
+ )
179
+
180
  # Launch the app
181
  iface.launch()