Update app.py
Browse files
app.py
CHANGED
|
@@ -141,8 +141,8 @@ def process_webpage(url):
|
|
| 141 |
rendered_content = get_youtube_transcript(url)
|
| 142 |
else:
|
| 143 |
# Fetch and parse webpage
|
| 144 |
-
response = requests.get(url)
|
| 145 |
-
soup = BeautifulSoup(response
|
| 146 |
html_content = str(soup.prettify())
|
| 147 |
|
| 148 |
for script in soup(["script", "style"]):
|
|
@@ -169,7 +169,7 @@ def process_webpage(url):
|
|
| 169 |
summary = summary_response.choices[0].message.content.strip()
|
| 170 |
perspectives = perspectives_response.choices[0].message.content.strip()
|
| 171 |
|
| 172 |
-
return
|
| 173 |
except Exception as e:
|
| 174 |
return f"Error fetching or processing content: {str(e)}", "", ""
|
| 175 |
|
|
@@ -310,19 +310,22 @@ with gr.Blocks() as demo:
|
|
| 310 |
url_input = gr.Textbox(label="Enter URL")
|
| 311 |
# Shared Button: Fetch content, show webpage, and summary/perspectives
|
| 312 |
fetch_btn = gr.Button("Fetch and Process Webpage")
|
| 313 |
-
text_output = gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
| 315 |
perspectives_output = gr.Textbox(label="Perspectives", lines=5)
|
| 316 |
|
| 317 |
-
# Column
|
| 318 |
with gr.Column():
|
| 319 |
-
gr.Markdown("## Interactive Chatbot")
|
| 320 |
chatbot_history_gr = gr.Chatbot(label="Chat History")
|
| 321 |
user_input = gr.Textbox(label="Ask a Question", placeholder="Type your question here...")
|
| 322 |
chatbot_btn = gr.Button("Chat")
|
| 323 |
|
| 324 |
-
# Column 3: Generate reflections
|
| 325 |
-
with gr.Column():
|
| 326 |
reflection_btn = gr.Button("Generate reflection")
|
| 327 |
reflection_output = gr.Textbox(label="Reflections",interactive=True, lines=5)
|
| 328 |
# Custom HTML and JS for copy-to-clipboard
|
|
|
|
| 141 |
rendered_content = get_youtube_transcript(url)
|
| 142 |
else:
|
| 143 |
# Fetch and parse webpage
|
| 144 |
+
response = requests.get(url).text
|
| 145 |
+
soup = BeautifulSoup(response, "html.parser")
|
| 146 |
html_content = str(soup.prettify())
|
| 147 |
|
| 148 |
for script in soup(["script", "style"]):
|
|
|
|
| 169 |
summary = summary_response.choices[0].message.content.strip()
|
| 170 |
perspectives = perspectives_response.choices[0].message.content.strip()
|
| 171 |
|
| 172 |
+
return response, summary, perspectives
|
| 173 |
except Exception as e:
|
| 174 |
return f"Error fetching or processing content: {str(e)}", "", ""
|
| 175 |
|
|
|
|
| 310 |
url_input = gr.Textbox(label="Enter URL")
|
| 311 |
# Shared Button: Fetch content, show webpage, and summary/perspectives
|
| 312 |
fetch_btn = gr.Button("Fetch and Process Webpage")
|
| 313 |
+
text_output = gr.HTML(label="Webpage Content", lines=7)
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
# Column 2: Interactive chatbot
|
| 317 |
+
with gr.Column():
|
| 318 |
+
gr.Markdown("## Summary and perspectives")
|
| 319 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
| 320 |
perspectives_output = gr.Textbox(label="Perspectives", lines=5)
|
| 321 |
|
| 322 |
+
# Column 3: Generate reflections
|
| 323 |
with gr.Column():
|
| 324 |
+
gr.Markdown("## Interactive Chatbot and reflections")
|
| 325 |
chatbot_history_gr = gr.Chatbot(label="Chat History")
|
| 326 |
user_input = gr.Textbox(label="Ask a Question", placeholder="Type your question here...")
|
| 327 |
chatbot_btn = gr.Button("Chat")
|
| 328 |
|
|
|
|
|
|
|
| 329 |
reflection_btn = gr.Button("Generate reflection")
|
| 330 |
reflection_output = gr.Textbox(label="Reflections",interactive=True, lines=5)
|
| 331 |
# Custom HTML and JS for copy-to-clipboard
|