Spaces:
Runtime error
Runtime error
Add app.py file
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
K = 5
|
5 |
+
|
6 |
+
|
7 |
+
def create_demo(callback):
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
with gr.Row():
|
10 |
+
with gr.Column():
|
11 |
+
fn = gr.Textbox(label="Company name", placeholder="Enter company name here...")
|
12 |
+
with gr.Row():
|
13 |
+
with gr.Column():
|
14 |
+
outs = [gr.Text(show_label=False) for _ in range(K)]
|
15 |
+
outs[0].label = "Similar company names"
|
16 |
+
outs[0].show_label = True
|
17 |
+
btn = gr.Button("Find similar companies", variant="primary")
|
18 |
+
btn.click(callback, inputs=fn, outputs=outs)
|
19 |
+
return demo
|
20 |
+
|
21 |
+
|
22 |
+
class Callback:
|
23 |
+
def __init__(self):
|
24 |
+
pass
|
25 |
+
|
26 |
+
def __call__(self, input_name):
|
27 |
+
res = ["These are completely different companies."] * K
|
28 |
+
return res
|
29 |
+
|
30 |
+
|
31 |
+
def main():
|
32 |
+
callback = Callback()
|
33 |
+
demo = create_demo(callback)
|
34 |
+
demo.launch()
|
35 |
+
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
main()
|