Spaces:
Runtime error
Runtime error
shravya commited on
Commit Β·
41c2364
1
Parent(s): 7b4a850
removed extra cards
Browse filesFiles changed (7)
- beautiful_code_logo.jpegDeleted
- pages.pyDeleted-35
- ui/article_recommendation.pyDeleted-108
- ui/course_lessons_extractor.pyDeleted-74
- ui/research_paper.pyDeleted-144
- ui/til_feedback.py-3
- ui_main.py+4-35
1234567891011121314151617181920212223242526272829303132333435# sidebar.py
import streamlit as stimport streamlit_router as sr
def common_sidebar(router): st.sidebar.markdown("# Sidebar Navigation") st.sidebar.markdown("---") st.sidebar.markdown("### Pages") if st.sidebar.button("Home"): router.redirect(*router.build('/')) if st.sidebar.button("TIL Feedback"): router.redirect(*router.build('/feedback')) if st.sidebar.button("Course Suggester"): router.redirect(*router.build('/course_suggester')) if st.sidebar.button("Course Lesson Extractor"): router.redirect(*router.build('/lessons_extractor')) if st.sidebar.button("Article Recommender"): router.redirect(*router.build('/article_recommendor')) if st.sidebar.button("Recent Article Suggester"): router.redirect(*router.build('/research_article_suggester'))
def with_sidebar(func): def wrapper(*args, **kwargs): from ui_main import router # Import router from the main file current_route = st.query_params.get("route", [""])[0] if current_route in ['feedback', 'course_suggester', 'lessons_extractor', 'article_recommendor', 'research_article_suggester']: common_sidebar(router) return func(*args, **kwargs) return wrapper
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108from dotenv import load_dotenvimport jsonimport streamlit as stimport utils.settings as settingsfrom workflows.article_suggestion import article_recommendation_crewfrom utils.write_to_json import write_dict_to_json as write_dict_to_jsonload_dotenv()settings.init()
def icon(emoji: str): """Shows an emoji as a Notion-style page icon.""" st.write( f'<span style="font-size: 78px; line-height: 1">{emoji}</span>', unsafe_allow_html=True, )
def article_recommendor_main(): page_bg_img = ''' <style> [data-testid="stAppViewContainer"]{ background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg"); background-size:cover; } [data-testid="stHeader"]{ background: rgba(0,0,0,0); } [data-testid="stToolbar"]{ right: 2rem; }
</style> ''' st.markdown(page_bg_img, unsafe_allow_html=True) icon("π Articles RecommendAIgent") st.subheader("Let AI agents recommend articles based on your interest!")
with st.sidebar: st.header("π Provide Your Interests Below!") with st.form("user_input_form", border=True): interests = st.text_input( "Enter your interests (comma-separated):", "GenAI, Architecture, Agentic Programming", ) previous_article_insights = st.text_area( "Enter previous article insights:", "Agentic Design Patterns (https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/)\n" "Reflection: The LLM examines its own work to come up with ways to improve it. " "Tool Use: The LLM is given tools such as web search, code execution, or any other function to help it gather information, take action, or process data. " "Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal " "Multi-agent collaboration: More than one AI agent work together, splitting up tasks and discussing and debating ideas, to come up with better solutions than a single agent would.\n\n" "GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n" "Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. " "Successful multi-agent systems act as a βdigital twinβ for your development team. " "Different Approaches: 1. Centralized, with one agent in the center that collects and assimilates all the other outputs. " "2. Distributed, where there is no central controller and the agents coordinate directly with one another in an βagent swarm. " "3. Hierarchical, where agents are organized in teams or hierarchical layers.\n\n" "LLM Model Quantisation\n" "Different Methods for Compression: Pruning, Knowledge Distiallation and Quantization." "Quantization process represents the model weights in lower precession which is also known as downcasting." "Quanitzatoin Error is the difference in the weights of the quantized model and the original model." "Advantages of Quanitzation: Reduced memory footprint, increased compute and speed of inferrence." "Disadvantages of Quantization: Less precise.\n\n", height=400, ) st.markdown("") submitted = st.form_submit_button("Submit")
if submitted: with st.status( "π€ **Agents at work...**", state="running", expanded=True ) as status: with st.container(height=500, border=False): result = article_recommendation_crew.kickoff( inputs={ "interests": interests, "previous_article_insights": previous_article_insights, } ) status.update( label="β
Articles are Ready for Reading!", state="complete", expanded=False, )
st.subheader("", anchor=False, divider="rainbow")
articles_list = settings.articles.values()
if articles_list is None: st.markdown("No articles found.") return else: for article in articles_list: st.markdown(f"# {article['title']}") st.markdown(f"**URL:** [{article['url']}]({article['url']})") st.markdown(f"**Pitch:** {article.get('pitch', '')}") st.markdown(f"**Evaluation Score:** {article.get('evaluation_score', '')}") st.markdown(f"**Evaluation Reason:** {article.get('evaluation_reason', '')}") st.markdown(f"**Reason For Recommendation:** {article.get('reason_for_recommendation', '')}") st.markdown("---")
if st.sidebar.button("β Back to Main Page"): st.session_state.page = "main"if __name__ == "__main__": article_recommendor_main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import streamlit as stimport asynciofrom contextlib import contextmanagerfrom dotenv import load_dotenvfrom workflows.courses.lessons_extractor import LessonsExtractorfrom streamlit_extras.capture import stdout
load_dotenv()
@contextmanagerdef setup_event_loop(): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: yield loop finally: loop.close() asyncio.set_event_loop(None)def lessons_extractor_main(): page_bg_img = ''' <style> [data-testid="stAppViewContainer"]{ background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg"); background-size:cover; } [data-testid="stHeader"]{ background: rgba(0,0,0,0); } [data-testid="stToolbar"]{ right: 2rem; }
</style> ''' st.markdown(page_bg_img, unsafe_allow_html=True) st.markdown("<div class='container'>", unsafe_allow_html=True)
st.markdown( """ <div class="centered"> <p class="title">Course Lesson Extractor</p> </div> """, unsafe_allow_html=True ) course_url = st.text_area('Enter the URL for the course:', "https://www.coursera.org/learn/google-data-analytics-capstone?specialization=google-data-analytics", key='course_url', help='Enter course you want to learn')
if st.button("Get Lessons"): with st.status( "π€ **Extracting Lessons...**", state="running", expanded=True ) as status: with st.container(height=500, border=False): log_container = st.empty() with stdout(log_container.code, terminator=""): with setup_event_loop() as loop: extractor = LessonsExtractor() inputs = {"course_url": course_url} results = extractor.kickoff(inputs=inputs)["lessons"] status.update( label="β
Extracted Lessons!", state="complete", expanded=False, )
for idx, lesson in enumerate(results): st.markdown(f"#### Lessons {idx}: {lesson['name']}") st.markdown(f"Concpets: {', '.join(lesson['concepts'])}")
if __name__ == "__main__": lessons_extractor_main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144import streamlit as stfrom workflows.research_article_suggester import RecentArticleSuggesterfrom streamlit_extras.capture import stdout
def research_article_suggester_main():
st.markdown( """ <style> # .main { # background-color: #f5f5f5; # padding: 20px; # border-radius: 10px; # } .centered { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; } .title { font-family: 'Helvetica', sans-serif; font-weight: bold; font-size: 36px; color: #1f77b4; } .description { font-family: 'Helvetica', sans-serif; font-size: 18px; color: #333333; margin-top: 10px; } .subheader { font-family: 'Helvetica', sans-serif; font-weight: bold; font-size: 24px; color: #ff7f0e; margin-top: 20px; } .element { background-color: #ffffff; padding: 1rem; border-radius: 8px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); margin-bottom: 1rem; } .element h3 { font-size: 24px; color: #1f77b4; margin-bottom: 0.5rem; text-transform: uppercase; padding :10px;
} .element ul { list-style-type: none; padding: 0; margin: 0; } .element li { font-size: 16px; color: #333333; margin-bottom: 0.5rem; } .element li b { font-size: 22px; } [data-testid="stAppViewContainer"]{ background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg"); background-size:cover; } [data-testid="stHeader"]{ background: rgba(0,0,0,0); } [data-testid="stToolbar"]{ right: 2rem; }
</style> """, unsafe_allow_html=True )
st.markdown("<div class='container'>", unsafe_allow_html=True)
st.markdown( """ <div class="centered"> <p class="title">Recent Article Suggester</p> <p class="description">Discover recent articles based on your topic of interest using advanced AI.</p> </div> """, unsafe_allow_html=True )
st.sidebar.markdown("<p class='sidebar-header'>Search for the papers you are interested in:</p>", 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('<p class="subheader">Results:</p>', unsafe_allow_html=True)
for element in results: st.markdown( f""" <div class="element"> <h3><a href="{element['url']}" target="_blank">{element['title']}</a></h3> <ul> {"".join(f"<li style='font-size: 20px;'><b>{key.capitalize()}:</b> {value}</li>" for key, value in element.items() if key != "title")} </ul> </div> """, unsafe_allow_html=True ) if st.sidebar.button("β Back to Main Page"): st.session_state.page = "main"if __name__ == "__main__": research_aricle_suggester_main()4 unmodified lines567891011121314154 unmodified linesfrom langsmith import Clientfrom workflows.utils.feedback import Feedbackload_dotenv()def feedback_main():page_bg_img = '''4 unmodified lines567891011124 unmodified linesfrom langsmith import Clientfrom workflows.utils.feedback import Feedbackload_dotenv()def feedback_main():page_bg_img = '''
123456789101116 unmodified lines28293031323334353624 unmodified lines616263646566676869707172737475767778798029 unmodified lines11011111211311411511614 unmodified lines13113213313413513613713814 unmodified lines1531541551561571581592 unmodified lines162163164165166167168169170171172173174175176177178179180181182183184185186from dotenv import load_dotenvfrom streamlit_extras.stylable_container import stylable_containerfrom ui.article_recommendation import article_recommendor_mainfrom ui.course_lessons_extractor import lessons_extractor_mainfrom ui.research_paper import research_article_suggester_mainfrom ui.til_feedback import feedback_mainfrom ui.course_learn_suggest_expectations import course_suggester_main# from pages import card_mainimport mathimport streamlit as stimport subprocess16 unmodified linesst.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_suggester_main_wrapper")))st.sidebar.button("Course Lesson Extractor", on_click=lambda: router.redirect(*router.build("lessons_extractor_main_wrapper")))st.sidebar.button("Article Recommender", on_click=lambda: router.redirect(*router.build("article_recommendor_main_wrapper")))st.sidebar.button("Recent Article Suggester", on_click=lambda: router.redirect(*router.build("research_article_suggester_main_wrapper")))def show_main_page():24 unmodified linesst.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>', unsafe_allow_html=True)st.markdown("---")# card_info = [# {"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper","image":"https://agent.ai/icons/search.svg"},# {"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper","image":"https://agent.ai/icons/prospecting.svg"},# {"title": "Course Lesson Extractor", "description": "Extract lessons for a given course", "key": "lessons_extractor_main_wrapper","image":"https://agent.ai/icons/business-analyst.svg"},# {"title": "Article Recommender", "description": "Discover articles tailored to your interests.", "key": "article_recommendor_main_wrapper","image":"https://agent.ai/icons/robot.svg"},# {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester_main_wrapper","image":"https://agent.ai/icons/data.svg"},# ]card_info = [{"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "π"},{"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper", "image": "π"},{"title": "Course Lesson Extractor", "description": "Extract lessons for a given course", "key": "lessons_extractor_main_wrapper", "image": "π"},{"title": "Article Recommender", "description": "Discover articles tailored to your interests.", "key": "article_recommendor_main_wrapper", "image": "π°"},{"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester_main_wrapper", "image": "π"},]num_cols = 329 unmodified linesmargin-bottom: 10px;} """,):# with st.container():st.markdown(f"""<div style="14 unmodified lines)if st.button("Explore", key=card["key"]):router.redirect(*router.build(f"{card['key']}"))# st.experimental_rerun()# st.session_state.page = card["key"]st.markdown("""14 unmodified lines""", unsafe_allow_html=True)# Wrapping each main page function to include the common sidebardef feedback_main_wrapper():common_sidebar()feedback_main()2 unmodified linescommon_sidebar()course_suggester_main()def lessons_extractor_main_wrapper():common_sidebar()lessons_extractor_main()def article_recommendor_main_wrapper():common_sidebar()article_recommendor_main()def research_article_suggester_main_wrapper():common_sidebar()research_article_suggester_main()router = sr.StreamlitRouter()router.register(show_main_page, '/')router.register(feedback_main_wrapper, '/feedback', methods=['GET'])router.register(course_suggester_main_wrapper, '/course_suggester')router.register(lessons_extractor_main_wrapper, '/lessons_extractor')router.register(article_recommendor_main_wrapper, '/article_recommendor')router.register(research_article_suggester_main_wrapper, '/research_article_suggester')router.serve()123456716 unmodified lines2425262728293024 unmodified lines5556575859606162636429 unmodified lines94959697989914 unmodified lines11411511611711811914 unmodified lines1341351361371381391402 unmodified lines143144145146147148149150151152153154155from dotenv import load_dotenvfrom streamlit_extras.stylable_container import stylable_containerfrom ui.til_feedback import feedback_mainfrom ui.course_learn_suggest_expectations import course_suggester_mainimport mathimport streamlit as stimport subprocess16 unmodified linesst.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_suggester_main_wrapper")))def show_main_page():24 unmodified linesst.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>', unsafe_allow_html=True)st.markdown("---")card_info = [{"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "π"},{"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper", "image": "π"},]num_cols = 329 unmodified linesmargin-bottom: 10px;} """,):st.markdown(f"""<div style="14 unmodified lines)if st.button("Explore", key=card["key"]):router.redirect(*router.build(f"{card['key']}"))st.markdown("""14 unmodified lines""", unsafe_allow_html=True)def feedback_main_wrapper():common_sidebar()feedback_main()2 unmodified linescommon_sidebar()course_suggester_main()router = sr.StreamlitRouter()router.register(show_main_page, '/')router.register(feedback_main_wrapper, '/feedback', methods=['GET'])router.register(course_suggester_main_wrapper, '/course_suggester')router.serve()
beautiful_code_logo.jpegDeleted
pages.pyDeleted-35
ui/article_recommendation.pyDeleted-108
ui/course_lessons_extractor.pyDeleted-74
ui/research_paper.pyDeleted-144
ui/til_feedback.py-3
ui_main.py+4-35