import streamlit as st
from crew.research_article_suggester import RecentArticleSuggester
from streamlit_extras.capture import stdout
def main():
st.set_page_config(page_title='Recent Article Suggester', page_icon='📰', layout='wide')
st.markdown(
"""
""",
unsafe_allow_html=True
)
st.markdown("
", unsafe_allow_html=True)
st.markdown(
"""
Recent Article Suggester
Discover recent articles based on your topic of interest using advanced AI.
""",
unsafe_allow_html=True
)
st.sidebar.markdown("", unsafe_allow_html=True)
topic = st.sidebar.text_input('Enter a topic:', 'GenAI', key='topic_input', help='Enter a topic of interest')
if st.sidebar.button('Get Suggestions'):
with st.status(
"🤖 **Agents at work...**", state="running", expanded=True
) as status:
with st.container(height=500, border=False):
log_container = st.empty()
with stdout(log_container.code, terminator=""):
suggester = RecentArticleSuggester()
inputs = {"topic": topic}
results = suggester.kickoff(inputs=inputs)
status.update(
label="✅ Articles are Ready for Reading!",
state="complete",
expanded=False,
)
st.subheader("", anchor=False, divider="rainbow")
if results is None:
st.markdown('No articles found.', unsafe_allow_html=True)
else:
st.markdown('', unsafe_allow_html=True)
for element in results:
st.markdown(
f"""
{"".join(f"- {key.capitalize()}: {value}
" for key, value in element.items() if key != "title")}
""",
unsafe_allow_html=True
)
if __name__ == "__main__":
main()