-
Notifications
You must be signed in to change notification settings - Fork 48
/
main_from_text.py
52 lines (41 loc) · 1.34 KB
/
main_from_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
import gradio as gr
from main import GPT4Wrapper, step3_get_lm_review
wrapper = GPT4Wrapper(model_name="gpt-4")
def process(title, abstract, figure_and_table_captions, main_content):
parsed_xml = {
"title": title,
"abstract": abstract,
"figure_and_table_captions": figure_and_table_captions,
"main_content": main_content,
}
review_generated = step3_get_lm_review(parsed_xml)
return review_generated["review_generated"]
def main():
example_paper = json.load(open("example_paper.json"))
input_fields = [
gr.Textbox(
label="Title",
placeholder=example_paper["Title"],
),
gr.Textbox(
label="Abstract",
lines=5,
placeholder=example_paper["Abstract"],
),
gr.Textbox(
label="Figures/Tables Captions",
lines=5,
placeholder=example_paper["Figures/Tables Captions"],
),
gr.Textbox(
label="Main Content", lines=15, placeholder=example_paper["Main Content"]
),
]
output_component_review = gr.Textbox(label="Review Generated")
demo = gr.Interface(
fn=process, inputs=input_fields, outputs=output_component_review
)
demo.launch(server_name="0.0.0.0", server_port=7799)
if __name__ == "__main__":
main()