raannakasturi commited on
Commit
e785663
1 Parent(s): b35a32c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -60
app.py CHANGED
@@ -1,60 +1,60 @@
1
- import os
2
- import sys
3
- from generate_markdown import load_llm_model, generate_markdown
4
- from generate_mindmap import generate_mindmap_svg
5
- import gradio as gr
6
- import subprocess
7
-
8
- def generate(file):
9
- print(f"Generating mindmap for {file}")
10
- summary = "This is a summary of the research paper"
11
- mindmap_markdown = generate_markdown(llm, file)
12
- mindmap_svg = generate_mindmap_svg(mindmap_markdown)
13
- print("Mindmap generated successfully")
14
- return summary, mindmap_markdown, mindmap_svg
15
-
16
- theme = gr.themes.Soft(
17
- primary_hue="purple",
18
- secondary_hue="cyan",
19
- neutral_hue="slate",
20
- font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins')],
21
- )
22
-
23
- with gr.Blocks(theme=theme, title="Binary Biology") as app:
24
- file = gr.File(file_count='single', label='Upload Research Paper PDF file', file_types=['.pdf'])
25
- summary = gr.TextArea(label='Summary', lines=5, interactive=False, show_copy_button=True)
26
- markdown_mindmap = gr.Textbox(label='Mindmap', lines=5, interactive=False, show_copy_button=True)
27
- graphical_mindmap = gr.Image(label='Graphical Mindmap', interactive=False, show_download_button=True, format='svg')
28
- submit = gr.Button(value='Submit')
29
-
30
- submit.click(generate,
31
- inputs=[file],
32
- outputs=[summary, markdown_mindmap, graphical_mindmap],
33
- scroll_to_output=True,
34
- show_progress=True,
35
- queue=True,
36
- )
37
-
38
- if __name__ == "__main__":
39
- try:
40
- env = os.environ.copy()
41
- env["CMAKE_ARGS"] = "-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
42
- cmd = ["pip", "install", "llama-cpp-python"]
43
- subprocess.run(cmd, env=env)
44
- except:
45
- cmd = ["pip", "install", "llama-cpp-python"]
46
- subprocess.run(cmd)
47
- try:
48
- try:
49
- subprocess.run(['apt', 'install', '-y', 'graphviz'])
50
- print("Graphviz installed successfully")
51
- except:
52
- subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
53
- print("Graphviz installed successfully using sudo")
54
- except:
55
- print("Graphviz installation failed")
56
- sys.exit(1)
57
- print("Graphviz loaded successfully")
58
- llm = load_llm_model()
59
- print("Model loaded successfully")
60
- app.queue(default_concurrency_limit=1).launch(show_error=True)
 
1
+ import os
2
+ import sys
3
+ from generate_markdown import load_llm_model, generate_markdown
4
+ from generate_mindmap import generate_mindmap_svg
5
+ import gradio as gr
6
+ import subprocess
7
+
8
+ def generate(file):
9
+ print(f"Generating mindmap for {file}")
10
+ summary = "This is a summary of the research paper"
11
+ mindmap_markdown = generate_markdown(llm, file)
12
+ mindmap_svg = generate_mindmap_svg(mindmap_markdown)
13
+ print("Mindmap generated successfully")
14
+ return summary, mindmap_markdown, mindmap_svg
15
+
16
+ theme = gr.themes.Soft(
17
+ primary_hue="purple",
18
+ secondary_hue="cyan",
19
+ neutral_hue="slate",
20
+ font=[gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins'), gr.themes.GoogleFont('poppins')],
21
+ )
22
+
23
+ with gr.Blocks(theme=theme, title="Binary Biology") as app:
24
+ file = gr.File(file_count='single', label='Upload Research Paper PDF file', file_types=['.pdf'])
25
+ summary = gr.TextArea(label='Summary', lines=5, interactive=False, show_copy_button=True)
26
+ markdown_mindmap = gr.Textbox(label='Mindmap', lines=5, interactive=False, show_copy_button=True)
27
+ graphical_mindmap = gr.Image(label='Graphical Mindmap', interactive=False, show_download_button=True, format='svg')
28
+ submit = gr.Button(value='Submit')
29
+
30
+ submit.click(generate,
31
+ inputs=[file],
32
+ outputs=[summary, markdown_mindmap, graphical_mindmap],
33
+ scroll_to_output=True,
34
+ show_progress=True,
35
+ queue=True,
36
+ )
37
+
38
+ if __name__ == "__main__":
39
+ try:
40
+ env = os.environ.copy()
41
+ env["CMAKE_ARGS"] = "-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
42
+ cmd = ["pip", "install", "llama-cpp-python"]
43
+ subprocess.run(cmd, env=env)
44
+ except:
45
+ cmd = ["pip", "install", "llama-cpp-python"]
46
+ subprocess.run(cmd)
47
+ try:
48
+ try:
49
+ subprocess.run(['apt', 'install', '-y', 'graphviz'])
50
+ print("Graphviz installed successfully")
51
+ except:
52
+ subprocess.run(['sudo', 'apt', 'install', '-y', 'graphviz'])
53
+ print("Graphviz installed successfully using sudo")
54
+ except:
55
+ print("Graphviz installation failed")
56
+ sys.exit(1)
57
+ print("Graphviz loaded successfully")
58
+ llm = load_llm_model()
59
+ print("Model loaded successfully")
60
+ app.queue(default_concurrency_limit=10).launch(show_error=True)