Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ from bs4 import BeautifulSoup
|
|
| 5 |
import PyPDF2
|
| 6 |
import docx
|
| 7 |
import time
|
| 8 |
-
from smolagents.agents import HuggingFaceAgent
|
| 9 |
|
| 10 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 11 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
|
@@ -77,9 +76,6 @@ def create_interface():
|
|
| 77 |
|
| 78 |
submit_button = gr.Button("Analyze")
|
| 79 |
progress_bar = gr.Progress()
|
| 80 |
-
|
| 81 |
-
model_endpoint = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
|
| 82 |
-
agent = HuggingFaceAgent(model_endpoint=model_endpoint)
|
| 83 |
|
| 84 |
def update_input_visibility(input_type):
|
| 85 |
return {
|
|
@@ -105,20 +101,16 @@ def create_interface():
|
|
| 105 |
|
| 106 |
try:
|
| 107 |
original_text, summary, sentiment, topics = analyze_text(input_value, input_type, tasks, progress_bar)
|
| 108 |
-
enhanced_summary = agent.run(f"Given the following text: '{original_text}', please suggest improvements to this summary: '{summary}'")
|
| 109 |
-
enhanced_sentiment = agent.run(f"Given the following text: '{original_text}', does this sentiment seem accurate: '{sentiment}'? Please elaborate and suggest any corrections.")
|
| 110 |
except Exception as e:
|
| 111 |
original_text = f"Error: {str(e)}"
|
| 112 |
summary, sentiment, topics = "", "", ""
|
| 113 |
-
enhanced_summary = ""
|
| 114 |
-
enhanced_sentiment = ""
|
| 115 |
|
| 116 |
-
return original_text, summary,
|
| 117 |
|
| 118 |
submit_button.click(
|
| 119 |
fn=process_input,
|
| 120 |
inputs=[input_type, text_input, url_input, file_input, tasks_checkboxes],
|
| 121 |
-
outputs=[original_text_output, summary_output,
|
| 122 |
)
|
| 123 |
|
| 124 |
interface = gr.TabbedInterface([
|
|
|
|
| 5 |
import PyPDF2
|
| 6 |
import docx
|
| 7 |
import time
|
|
|
|
| 8 |
|
| 9 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 10 |
sentiment_analyzer = pipeline("sentiment-analysis")
|
|
|
|
| 76 |
|
| 77 |
submit_button = gr.Button("Analyze")
|
| 78 |
progress_bar = gr.Progress()
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
def update_input_visibility(input_type):
|
| 81 |
return {
|
|
|
|
| 101 |
|
| 102 |
try:
|
| 103 |
original_text, summary, sentiment, topics = analyze_text(input_value, input_type, tasks, progress_bar)
|
|
|
|
|
|
|
| 104 |
except Exception as e:
|
| 105 |
original_text = f"Error: {str(e)}"
|
| 106 |
summary, sentiment, topics = "", "", ""
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
return original_text, summary, sentiment, topics
|
| 109 |
|
| 110 |
submit_button.click(
|
| 111 |
fn=process_input,
|
| 112 |
inputs=[input_type, text_input, url_input, file_input, tasks_checkboxes],
|
| 113 |
+
outputs=[original_text_output, summary_output, sentiment_output, topics_output]
|
| 114 |
)
|
| 115 |
|
| 116 |
interface = gr.TabbedInterface([
|