File size: 4,000 Bytes
c57baf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cb73d5
c57baf4
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import gradio as gr
from functionality import get_collection, predict

def read_file(file):
    if file is not None:
        with open(file.name, 'r') as f:
            file_data = f.read()
        return file_data
    else:
        return None

with gr.Blocks() as demo:
    gr.Markdown("# **πŸ“ AI-powered Academic Research Assistant πŸ“**")
    gr.Markdown("""**AI-powered Academic Research Assistant** is a tool which helps to 
                ensure the *correct grammar* and *academic style* in the scientific papers.

                It also could help with *writing needed parts* or *proposing possible ideas*
                for describing what you want in appropriate way.

                ## πŸ“₯ Down bellow you should choose appropriate parameters for your goals and then wait a little for the responce!""")

    gr.Markdown('πŸ“¨ Write the text you what to expand or upload corresponding text file.')    

    with gr.Tab('Write Text πŸ“–'):
        gr.Markdown("βš™οΈ *Hint*: to ensure more effective work of 'Fix Academic Style' try to make your sentences not too long (<= 20 words).")
        input_prompt = gr.Textbox(label='Initial Text πŸ“',
                            placeholder='Write here your research text!',
                            lines=9,)
    with gr.Tab('Upload File πŸ“©'):
        gr.Markdown("βš™οΈ *Hint*: to ensure more effective work of 'Fix Academic Style' try to make your sentences not too long (<= 20 words).")
        txt_file = gr.File(file_types=['text',], label='Upload Text File',)
        txt_file.change(read_file, inputs=txt_file, outputs=input_prompt)

            
    gr.Markdown('✏️ Fill parameters for your needs')
    with gr.Row(variant='panel', equal_height=True):
        request_goal = gr.Radio(label='πŸ€” Specify the purpose of your request.',
                                info="Pick one:",
                                choices=['Write Text (Part)', 'Fix Academic Style', 'Fix Grammar', ],
                                value='Write Text (Part)',)
        
        with gr.Accordion("❗️ In case you need to Write Text (Part) choose appropriate option!", open=False):
            part_to_write = gr.CheckboxGroup(label="""πŸ“‹ What part for Assistant to write? (here you need to 
                                             specify what part of your research you need to complete.)""", 
                                            info="""You may chose as many as needed:""",
                                            choices=['Abstract', 'Introduction', 
                                                     'Methodology', 'Discussion', 'Conclusion', 'Full Text',],
                                            value='Abstract',)
    
    with gr.Row(equal_height=True):
        submit_btn = gr.Button('Confirm! βœ…')
        clear_btn = gr.Button('Clear ❌', min_width=611)

    gr.Markdown('##### πŸ“Œ Assistant Responce')
    gr.Markdown("In case you did not satisfy with the responce try to paraphrase!")

    responce = gr.Textbox(label="Generated Text πŸ‘¨πŸΌβ€πŸ’»", 
                        info="""You may face some page jumps, it is a bug which will be fixed. Just wait for the completion of text generation. 
                        Sorry for inconvenience(""",
                        lines=9, 
                        placeholder='Here the generated text will appear!', 
                        show_label=True,
                        show_copy_button=True,
                        autofocus=True, 
                        autoscroll=True,)
    
    submit_btn.click(fn=predict, 
                    inputs=[request_goal, part_to_write, input_prompt,], 
                    outputs=[responce], 
                    scroll_to_output=True, queue=True)
    clear_btn.click(lambda: (None, None, 'Write Text (Part)', 'Abstract', None), None, 
                outputs=[input_prompt, txt_file, request_goal, part_to_write, responce])

if __name__ == "__main__":
    get_collection()
    demo.launch()