Update app.py
Browse files
app.py
CHANGED
|
@@ -80,77 +80,19 @@ def summarize_content(pdf_file, text_input, conciseness):
|
|
| 80 |
final_summary = summarize_chunks(chunks, conciseness)
|
| 81 |
return final_summary
|
| 82 |
|
| 83 |
-
FOOTER_TEXT = """
|
| 84 |
-
<footer>
|
| 85 |
-
<p>If you enjoyed the functionality of the app, please leave a like!<br>
|
| 86 |
-
Check out more on
|
| 87 |
-
<a href="https://www.linkedin.com/in/girish-wangikar/" target="_blank">LinkedIn</a> |
|
| 88 |
-
<a href="https://girishwangikar.github.io/Girish_Wangikar_Portfolio.github.io/" target="_blank">Portfolio</a>
|
| 89 |
-
</p>
|
| 90 |
-
</footer>
|
| 91 |
-
"""
|
| 92 |
-
|
| 93 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
| 94 |
-
# Add custom CSS for styling
|
| 95 |
-
gr.Markdown(
|
| 96 |
-
"""
|
| 97 |
-
<style>
|
| 98 |
-
.title {
|
| 99 |
-
text-align: center;
|
| 100 |
-
}
|
| 101 |
-
.description {
|
| 102 |
-
text-align: center;
|
| 103 |
-
}
|
| 104 |
-
footer {
|
| 105 |
-
text-align: center;
|
| 106 |
-
padding: 10px;
|
| 107 |
-
width: 100%;
|
| 108 |
-
background-color: rgba(240, 240, 240, 0.8);
|
| 109 |
-
z-index: 1000;
|
| 110 |
-
position: relative;
|
| 111 |
-
margin-top: 10px;
|
| 112 |
-
color: black;
|
| 113 |
-
}
|
| 114 |
-
/* Optional: Adjust link styles in footer */
|
| 115 |
-
footer a {
|
| 116 |
-
color: #1a0dab;
|
| 117 |
-
text-decoration: none;
|
| 118 |
-
}
|
| 119 |
-
footer a:hover {
|
| 120 |
-
text-decoration: underline;
|
| 121 |
-
}
|
| 122 |
-
</style>
|
| 123 |
-
"""
|
| 124 |
-
)
|
| 125 |
-
|
| 126 |
-
# Title and Description with center alignment
|
| 127 |
gr.Markdown(
|
| 128 |
"""
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
</div>
|
| 132 |
-
<div class="description">
|
| 133 |
-
### Advanced PDF and Text Summarization with Conciseness Control
|
| 134 |
-
- Upload your PDF document or enter text directly, adjust the conciseness level, and let AI generate a summary.
|
| 135 |
-
</div>
|
| 136 |
"""
|
| 137 |
)
|
| 138 |
|
| 139 |
with gr.Row():
|
| 140 |
with gr.Column(scale=1):
|
| 141 |
input_pdf = gr.File(label="Upload PDF (optional)", file_types=[".pdf"])
|
| 142 |
-
input_text = gr.Textbox(
|
| 143 |
-
|
| 144 |
-
lines=5,
|
| 145 |
-
placeholder="Paste or type your text here..."
|
| 146 |
-
)
|
| 147 |
-
conciseness_slider = gr.Slider(
|
| 148 |
-
minimum=0,
|
| 149 |
-
maximum=1,
|
| 150 |
-
value=0.5,
|
| 151 |
-
step=0.1,
|
| 152 |
-
label="Conciseness Level"
|
| 153 |
-
)
|
| 154 |
submit_btn = gr.Button("Generate Summary", variant="primary")
|
| 155 |
|
| 156 |
with gr.Column(scale=2):
|
|
@@ -159,24 +101,26 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
| 159 |
gr.Markdown(
|
| 160 |
"""
|
| 161 |
### How it works
|
| 162 |
-
1.
|
| 163 |
-
2.
|
| 164 |
- 0 (Most detailed) to 1 (Most concise)
|
| 165 |
-
3.
|
| 166 |
-
4.
|
| 167 |
-
5.
|
| 168 |
*Powered by LLAMA 3.1 8B model and LangChain*
|
| 169 |
"""
|
| 170 |
)
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
)
|
| 181 |
|
|
|
|
|
|
|
| 182 |
iface.launch()
|
|
|
|
| 80 |
final_summary = summarize_chunks(chunks, conciseness)
|
| 81 |
return final_summary
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
gr.Markdown(
|
| 85 |
"""
|
| 86 |
+
<h1 style="text-align: center;">PDF And Text Summarizer</h1>
|
| 87 |
+
<h3 style="text-align: center;">Advanced PDF and Text Summarization with Conciseness Control - Upload your PDF document or enter text directly, adjust the conciseness level, and let AI generate a summary.</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
"""
|
| 89 |
)
|
| 90 |
|
| 91 |
with gr.Row():
|
| 92 |
with gr.Column(scale=1):
|
| 93 |
input_pdf = gr.File(label="Upload PDF (optional)", file_types=[".pdf"])
|
| 94 |
+
input_text = gr.Textbox(label="Or enter text here", lines=5, placeholder="Paste or type your text here...")
|
| 95 |
+
conciseness_slider = gr.Slider(minimum=0, maximum=1, value=0.5, step=0.1, label="Conciseness Level")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
submit_btn = gr.Button("Generate Summary", variant="primary")
|
| 97 |
|
| 98 |
with gr.Column(scale=2):
|
|
|
|
| 101 |
gr.Markdown(
|
| 102 |
"""
|
| 103 |
### How it works
|
| 104 |
+
1. Upload a PDF file or enter text directly
|
| 105 |
+
2. Adjust the conciseness level:
|
| 106 |
- 0 (Most detailed) to 1 (Most concise)
|
| 107 |
+
3. Click "Generate Summary"
|
| 108 |
+
4. Wait for the AI to process and summarize your content
|
| 109 |
+
5. Review the generated summary
|
| 110 |
*Powered by LLAMA 3.1 8B model and LangChain*
|
| 111 |
"""
|
| 112 |
)
|
| 113 |
|
| 114 |
+
gr.HTML(
|
| 115 |
+
"""
|
| 116 |
+
<footer>
|
| 117 |
+
<p>If you enjoyed the functionality of the app, please leave a like!<br>
|
| 118 |
+
Check out more on <a href="https://www.linkedin.com/in/girish-wangikar/" target="_blank">LinkedIn</a> |
|
| 119 |
+
<a href="https://girishwangikar.github.io/Girish_Wangikar_Portfolio.github.io/" target="_blank">Portfolio</a></p>
|
| 120 |
+
</footer>
|
| 121 |
+
"""
|
| 122 |
)
|
| 123 |
|
| 124 |
+
submit_btn.click(summarize_content, inputs=[input_pdf, input_text, conciseness_slider], outputs=output)
|
| 125 |
+
|
| 126 |
iface.launch()
|