Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -250,7 +250,7 @@ def save_text_to_pdf(text, output_path):
|
|
250 |
print(f"Text saved to PDF at {output_path}")
|
251 |
|
252 |
# Function to process the PDF or search query and generate a summary
|
253 |
-
def process_input(query_or_file, is_pdf, instructions,
|
254 |
load_dotenv() # Load environment variables from .env file
|
255 |
|
256 |
HUGGINGFACE_API_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
@@ -309,7 +309,6 @@ def summarization_interface():
|
|
309 |
pdf_top_p = gr.Slider(label="Top P", minimum=0.0, maximum=1.0, value=0.9, step=0.01)
|
310 |
pdf_repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=0.5, maximum=2.0, value=1.0, step=0.1)
|
311 |
pdf_summary_output = gr.Textbox(label="Summary Output")
|
312 |
-
pdf_api_key = gr.Textbox(label="Hugging Face API Key", type="password")
|
313 |
pdf_summarize_button = gr.Button("Generate Summary")
|
314 |
pdf_clear_cache_button = gr.Button("Clear Cache")
|
315 |
|
@@ -320,13 +319,12 @@ def summarization_interface():
|
|
320 |
search_top_p = gr.Slider(label="Top P", minimum=0.0, maximum=1.0, value=0.9, step=0.01)
|
321 |
search_repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=0.5, maximum=2.0, value=1.0, step=0.1)
|
322 |
search_summary_output = gr.Textbox(label="Summary Output")
|
323 |
-
search_api_key = gr.Textbox(label="Hugging Face API Key", type="password")
|
324 |
search_summarize_button = gr.Button("Generate Summary")
|
325 |
search_clear_cache_button = gr.Button("Clear Cache")
|
326 |
|
327 |
# Bind functions to button clicks
|
328 |
-
pdf_summarize_button.click(fn=lambda file, instructions,
|
329 |
-
search_summarize_button.click(fn=lambda query, instructions,
|
330 |
pdf_clear_cache_button.click(fn=clear_cache, inputs=None, outputs=pdf_summary_output)
|
331 |
search_clear_cache_button.click(fn=clear_cache, inputs=None, outputs=search_summary_output)
|
332 |
|
|
|
250 |
print(f"Text saved to PDF at {output_path}")
|
251 |
|
252 |
# Function to process the PDF or search query and generate a summary
|
253 |
+
def process_input(query_or_file, is_pdf, instructions, temperature, top_p, repetition_penalty):
|
254 |
load_dotenv() # Load environment variables from .env file
|
255 |
|
256 |
HUGGINGFACE_API_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
|
|
309 |
pdf_top_p = gr.Slider(label="Top P", minimum=0.0, maximum=1.0, value=0.9, step=0.01)
|
310 |
pdf_repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=0.5, maximum=2.0, value=1.0, step=0.1)
|
311 |
pdf_summary_output = gr.Textbox(label="Summary Output")
|
|
|
312 |
pdf_summarize_button = gr.Button("Generate Summary")
|
313 |
pdf_clear_cache_button = gr.Button("Clear Cache")
|
314 |
|
|
|
319 |
search_top_p = gr.Slider(label="Top P", minimum=0.0, maximum=1.0, value=0.9, step=0.01)
|
320 |
search_repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=0.5, maximum=2.0, value=1.0, step=0.1)
|
321 |
search_summary_output = gr.Textbox(label="Summary Output")
|
|
|
322 |
search_summarize_button = gr.Button("Generate Summary")
|
323 |
search_clear_cache_button = gr.Button("Clear Cache")
|
324 |
|
325 |
# Bind functions to button clicks
|
326 |
+
pdf_summarize_button.click(fn=lambda file, instructions, temperature, top_p, repetition_penalty: process_input(file, True, instructions, temperature, top_p, repetition_penalty), inputs=[pdf_file, pdf_instructions, pdf_temperature, pdf_top_p, pdf_repetition_penalty], outputs=pdf_summary_output)
|
327 |
+
search_summarize_button.click(fn=lambda query, instructions, temperature, top_p, repetition_penalty: process_input(query, False, instructions, temperature, top_p, repetition_penalty), inputs=[search_query, search_instructions, search_temperature, search_top_p, search_repetition_penalty], outputs=search_summary_output)
|
328 |
pdf_clear_cache_button.click(fn=clear_cache, inputs=None, outputs=pdf_summary_output)
|
329 |
search_clear_cache_button.click(fn=clear_cache, inputs=None, outputs=search_summary_output)
|
330 |
|