TheHickman commited on
Commit
66b1fce
·
verified ·
1 Parent(s): 60bcad1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -55
app.py CHANGED
@@ -179,63 +179,60 @@ await inference.conversational({
179
  Thanks to the template, you can deploy your own instance based on a large language model with only a few clicks and customize it. Learn more about it here and create your large language model instance here.
180
  </div>
181
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
 
183
  def switch_content(choice):
184
- if choice == "My Work":
185
- return YOUR_WORK_HTML
186
- else:
187
- return HF_REFERENCE_HTML
188
-
189
- with gr.Blocks(head="""
190
- <script>
191
- document.addEventListener("mouseup", () => {
192
- const selection = window.getSelection().toString().trim();
193
- if (selection.length > 0) {
194
- const textbox = document.querySelector('textarea[data-testid="textbox"]');
195
- if (textbox) {
196
- const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
197
- window.HTMLTextAreaElement.prototype,
198
- "value"
199
- ).set;
200
- nativeInputValueSetter.call(textbox, selection);
201
- textbox.dispatchEvent(new Event("input", { bubbles: true }));
202
- }
203
  }
204
- });
205
- </script>
206
- """) as demo:
207
- gr.Markdown("### 📘 Highlight text and ask GPT for help")
208
-
209
- # Toggle between your work and HF reference
210
- #view_toggle = gr.Radio(
211
- # choices=["My Work", "HF Reference"],
212
- # value="My Work",
213
- # label="View",
214
- # interactive=True
215
- #)
216
-
217
- content_display = gr.HTML(HF_REFERENCE_HTML)
218
-
219
- #view_toggle.change(
220
- # fn=switch_content,
221
- # inputs=view_toggle,
222
- # outputs=content_display
223
- #)
224
-
225
- selected_text = gr.Textbox(
226
- label="Selected text",
227
- placeholder="Highlight text above...",
228
- lines=3,
229
- interactive=True
230
- )
231
-
232
- explain_btn = gr.Button("Explain selection 🧠")
233
- output = gr.Markdown()
234
-
235
- explain_btn.click(
236
- fn=explain_text,
237
- inputs=selected_text,
238
- outputs=output,
239
- )
240
 
241
  demo.launch(allowed_paths=["."])
 
179
  Thanks to the template, you can deploy your own instance based on a large language model with only a few clicks and customize it. Learn more about it here and create your large language model instance here.
180
  </div>
181
  """
182
+
183
+ # ---- Placeholder HTML pages ----
184
+ TEXT_GENERATION_HTML = HF_REFERENCE_HTML
185
+
186
+ QUESTION_ANSWER_HTML = """
187
+ <div style="max-width: 800px; margin: auto;">
188
+ <h1>Question and Answer</h1>
189
+ <p>Q&A content goes here...</p>
190
+ </div>
191
+ """
192
+
193
+ SUMMARISATION_HTML = """
194
+ <div style="max-width: 800px; margin: auto;">
195
+ <h1>Summarisation</h1>
196
+ <p>Summarisation content goes here...</p>
197
+ </div>
198
+ """
199
+
200
+ IMAGE_GENERATION_HTML = """
201
+ <div style="max-width: 800px; margin: auto;">
202
+ <h1>Image Generation</h1>
203
+ <p>Image generation content goes here...</p>
204
+ </div>
205
+ """
206
 
207
+ # ---- Page switching function ----
208
  def switch_content(choice):
209
+ pages = {
210
+ "Text Generation": TEXT_GENERATION_HTML,
211
+ "Question and Answer": QUESTION_ANSWER_HTML,
212
+ "Summarisation": SUMMARISATION_HTML,
213
+ "Image Generation": IMAGE_GENERATION_HTML,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
+ return pages.get(choice, TEXT_GENERATION_HTML)
216
+
217
+ nav_bar = gr.Radio(
218
+ choices=[
219
+ "Text Generation",
220
+ "Question and Answer",
221
+ "Summarisation",
222
+ "Image Generation"
223
+ ],
224
+ value="Text Generation",
225
+ label="Topics",
226
+ interactive=True
227
+ )
228
+
229
+ content_display = gr.HTML(TEXT_GENERATION_HTML)
230
+
231
+ nav_bar.change(
232
+ fn=switch_content,
233
+ inputs=nav_bar,
234
+ outputs=content_display
235
+ )
236
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  demo.launch(allowed_paths=["."])