-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
28 lines (23 loc) · 865 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
from src.pipeline.rag_pipeline import RAGPipeline
from src.components.web_scraper import scrape_news
# Scrape news documents
url = ["https://www.bbc.com/news",
"https://www.bbc.co.uk/news/england"]
documents = scrape_news(url)
if not documents:
st.error("No news articles found from the website")
else:
# Initialize the chatbot pipeline with the scraped news documents
chatbot = RAGPipeline(documents)
# Streamlit app UI
st.title("News Chatbot (using BBC)")
# User input for querying the chatbot
query = st.text_input("Ask me about news today:")
# Button to get the chatbot's response
if st.button("Get Answer"):
if query:
response = chatbot.run(query)
st.write("**Chatbot Response:**", response)
else:
st.warning("Please enter a question!")