ChancesYuan commited on
Commit
6dd01fc
1 Parent(s): a0a66d7
Files changed (1) hide show
  1. app.py +34 -4
app.py CHANGED
@@ -1,7 +1,37 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ def generate_text(title, context):
4
+ return f"Title:{title}\nContext:{context}\n..."
5
 
6
+ def generate_mutimodal(title, context, img):
7
+ return f"Title:{title}\nContext:{context}\n...{img}"
8
+
9
+ with gr.Blocks() as demo:
10
+ gr.Markdown("# KGE Editing")
11
+
12
+ # 多个tab
13
+ with gr.Tabs():
14
+
15
+ with gr.TabItem("E-FB15k237"):
16
+ title = gr.Textbox(label="Input", lines=1, placeholder="Mask triple input")
17
+ origin_button = gr.Button("Origin")
18
+ origin_output = gr.Textbox(label="Before Edit", lines=2, placeholder="")
19
+
20
+ alter_label = gr.Textbox(label="Alter Entity", lines=1, placeholder="Entity Name")
21
+ edit_button = gr.Button("Edit")
22
+
23
+ edit_output = gr.Textbox(label="After Edit", lines=2, placeholder="")
24
+
25
+ with gr.TabItem("A-FB15k237"):
26
+ title = gr.Textbox(label="Input", lines=1, placeholder="New triple input")
27
+
28
+ alter_label = gr.Textbox(label="Head/Tail", lines=1, placeholder="1:head / 0:tail")
29
+ add_button = gr.Button("Add")
30
+
31
+ add_output = gr.Textbox(label="Add Results", lines=2, placeholder="")
32
+
33
+
34
+ edit_button.click(fn=generate_text, inputs=[title, alter_label], outputs=edit_output)
35
+ add_button.click(fn=generate_mutimodal, inputs=[title, alter_label], outputs=add_output)
36
+
37
+ demo.launch()