Brian Watson commited on
Commit
0927694
·
1 Parent(s): b965088

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -55,6 +55,32 @@ with gr.Blocks(css=css) as myface:
55
  <meta property="og:description" content="Tweet Genie - A Huggingface Space"/>
56
  <meta property="og:image" content="https://cdn.glitch.global/80dbe92e-ce75-44af-84d5-74a2e21e9e55/omnicard.png?v=1676772531627"/>
57
  <!--<meta http-equiv="refresh" content="0; url=https://huggingface.co/spaces/corbt/tweet-genie">-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </head>
59
  </html>
60
  """
@@ -67,9 +93,10 @@ with gr.Blocks(css=css) as myface:
67
  model_name1 = gr.Dropdown(
68
  label="Choose Model",
69
  choices=[m["name"] for m in models],
70
- type="auto_complete",
71
  value=current_model["name"],
72
  interactive=True,
 
73
  )
74
  with gr.Row():
75
  see_prompts = gr.Button("Generate Prompts")
@@ -118,4 +145,4 @@ with gr.Blocks(css=css) as myface:
118
  see_prompts.click(text_it, inputs=[input_text], outputs=[magic8])
119
 
120
  myface.queue(concurrency_count=200)
121
- myface.launch(inline=True, show_api=False, max_threads=400)
 
55
  <meta property="og:description" content="Tweet Genie - A Huggingface Space"/>
56
  <meta property="og:image" content="https://cdn.glitch.global/80dbe92e-ce75-44af-84d5-74a2e21e9e55/omnicard.png?v=1676772531627"/>
57
  <!--<meta http-equiv="refresh" content="0; url=https://huggingface.co/spaces/corbt/tweet-genie">-->
58
+ <script>
59
+ function makeDropdownSearchable(dropdownId) {
60
+ const input = document.getElementById(dropdownId);
61
+ input.addEventListener("input", function() {
62
+ const value = this.value.toLowerCase();
63
+ const options = document.querySelectorAll(`#${dropdownId} option`);
64
+ let found = false;
65
+ for (let i = 0; i < options.length; i++) {
66
+ const option = options[i];
67
+ const text = option.text.toLowerCase();
68
+ const match = text.includes(value);
69
+ option.style.display = match ? "block" : "none";
70
+ if (match) {
71
+ found = true;
72
+ }
73
+ }
74
+ if (value && !found) {
75
+ const firstOption = options[0];
76
+ if (firstOption) {
77
+ firstOption.selected = true;
78
+ }
79
+ }
80
+ });
81
+ }
82
+ makeDropdownSearchable("model_dropdown");
83
+ </script>
84
  </head>
85
  </html>
86
  """
 
93
  model_name1 = gr.Dropdown(
94
  label="Choose Model",
95
  choices=[m["name"] for m in models],
96
+ type="index",
97
  value=current_model["name"],
98
  interactive=True,
99
+ key="model_dropdown"
100
  )
101
  with gr.Row():
102
  see_prompts = gr.Button("Generate Prompts")
 
145
  see_prompts.click(text_it, inputs=[input_text], outputs=[magic8])
146
 
147
  myface.queue(concurrency_count=200)
148
+ myface.launch(inline=True, show_api=False, max_threads=400