Spaces:
Runtime error
Runtime error
Merge pull request #26 from beautiful-code/ui/cleanup
Browse files- beautiful_code_logo.jpeg +0 -0
- ui/article_recommendation.py +0 -109
- ui/course_learn_suggest_expectations.py +4 -2
- ui/course_lessons_extractor.py +0 -74
- ui/research_paper.py +0 -142
- ui/til_feedback.py +2 -0
- ui_main.py +101 -94
beautiful_code_logo.jpeg
DELETED
|
Binary file (11.8 kB)
|
|
|
ui/article_recommendation.py
DELETED
|
@@ -1,109 +0,0 @@
|
|
| 1 |
-
from dotenv import load_dotenv
|
| 2 |
-
import json
|
| 3 |
-
import streamlit as st
|
| 4 |
-
import utils.settings as settings
|
| 5 |
-
|
| 6 |
-
from workflows.article_suggestion import article_recommendation_crew
|
| 7 |
-
from utils.write_to_json import write_dict_to_json as write_dict_to_json
|
| 8 |
-
load_dotenv()
|
| 9 |
-
settings.init()
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def icon(emoji: str):
|
| 13 |
-
"""Shows an emoji as a Notion-style page icon."""
|
| 14 |
-
st.write(
|
| 15 |
-
f'<span style="font-size: 78px; line-height: 1">{emoji}</span>',
|
| 16 |
-
unsafe_allow_html=True,
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def main():
|
| 21 |
-
page_bg_img = '''
|
| 22 |
-
<style>
|
| 23 |
-
[data-testid="stAppViewContainer"]{
|
| 24 |
-
background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg");
|
| 25 |
-
background-size:cover;
|
| 26 |
-
}
|
| 27 |
-
[data-testid="stHeader"]{
|
| 28 |
-
background: rgba(0,0,0,0);
|
| 29 |
-
}
|
| 30 |
-
[data-testid="stToolbar"]{
|
| 31 |
-
right: 2rem;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
</style>
|
| 36 |
-
'''
|
| 37 |
-
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 38 |
-
icon("π Articles RecommendAIgent")
|
| 39 |
-
st.subheader("Let AI agents recommend articles based on your interest!")
|
| 40 |
-
|
| 41 |
-
with st.sidebar:
|
| 42 |
-
st.header("π Provide Your Interests Below!")
|
| 43 |
-
with st.form("user_input_form", border=True):
|
| 44 |
-
interests = st.text_input(
|
| 45 |
-
"Enter your interests (comma-separated):",
|
| 46 |
-
"GenAI, Architecture, Agentic Programming",
|
| 47 |
-
)
|
| 48 |
-
previous_article_insights = st.text_area(
|
| 49 |
-
"Enter previous article insights:",
|
| 50 |
-
"Agentic Design Patterns (https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/)\n"
|
| 51 |
-
"Reflection: The LLM examines its own work to come up with ways to improve it. "
|
| 52 |
-
"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. "
|
| 53 |
-
"Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
|
| 54 |
-
"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"
|
| 55 |
-
"GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n"
|
| 56 |
-
"Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. "
|
| 57 |
-
"Successful multi-agent systems act as a βdigital twinβ for your development team. "
|
| 58 |
-
"Different Approaches: 1. Centralized, with one agent in the center that collects and assimilates all the other outputs. "
|
| 59 |
-
"2. Distributed, where there is no central controller and the agents coordinate directly with one another in an βagent swarm. "
|
| 60 |
-
"3. Hierarchical, where agents are organized in teams or hierarchical layers.\n\n"
|
| 61 |
-
"LLM Model Quantisation\n"
|
| 62 |
-
"Different Methods for Compression: Pruning, Knowledge Distiallation and Quantization."
|
| 63 |
-
"Quantization process represents the model weights in lower precession which is also known as downcasting."
|
| 64 |
-
"Quanitzatoin Error is the difference in the weights of the quantized model and the original model."
|
| 65 |
-
"Advantages of Quanitzation: Reduced memory footprint, increased compute and speed of inferrence."
|
| 66 |
-
"Disadvantages of Quantization: Less precise.\n\n",
|
| 67 |
-
height=400,
|
| 68 |
-
)
|
| 69 |
-
st.markdown("")
|
| 70 |
-
submitted = st.form_submit_button("Submit")
|
| 71 |
-
|
| 72 |
-
if submitted:
|
| 73 |
-
with st.status(
|
| 74 |
-
"π€ **Agents at work...**", state="running", expanded=True
|
| 75 |
-
) as status:
|
| 76 |
-
with st.container(height=500, border=False):
|
| 77 |
-
result = article_recommendation_crew.kickoff(
|
| 78 |
-
inputs={
|
| 79 |
-
"interests": interests,
|
| 80 |
-
"previous_article_insights": previous_article_insights,
|
| 81 |
-
}
|
| 82 |
-
)
|
| 83 |
-
status.update(
|
| 84 |
-
label="β
Articles are Ready for Reading!",
|
| 85 |
-
state="complete",
|
| 86 |
-
expanded=False,
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
st.subheader("", anchor=False, divider="rainbow")
|
| 90 |
-
|
| 91 |
-
articles_list = settings.articles.values()
|
| 92 |
-
|
| 93 |
-
if articles_list is None:
|
| 94 |
-
st.markdown("No articles found.")
|
| 95 |
-
return
|
| 96 |
-
else:
|
| 97 |
-
for article in articles_list:
|
| 98 |
-
st.markdown(f"# {article['title']}")
|
| 99 |
-
st.markdown(f"**URL:** [{article['url']}]({article['url']})")
|
| 100 |
-
st.markdown(f"**Pitch:** {article.get('pitch', '')}")
|
| 101 |
-
st.markdown(f"**Evaluation Score:** {article.get('evaluation_score', '')}")
|
| 102 |
-
st.markdown(f"**Evaluation Reason:** {article.get('evaluation_reason', '')}")
|
| 103 |
-
st.markdown(f"**Reason For Recommendation:** {article.get('reason_for_recommendation', '')}")
|
| 104 |
-
st.markdown("---")
|
| 105 |
-
|
| 106 |
-
if st.sidebar.button("β Back to Main Page"):
|
| 107 |
-
st.session_state.page = "main"
|
| 108 |
-
if __name__ == "__main__":
|
| 109 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui/course_learn_suggest_expectations.py
CHANGED
|
@@ -4,7 +4,9 @@ from streamlit_extras.stylable_container import stylable_container
|
|
| 4 |
from workflows.courses.expectation_revision import ExpectationRevision
|
| 5 |
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
st.markdown("""
|
| 9 |
<style>
|
| 10 |
[data-testid="stAppViewContainer"]{
|
|
@@ -146,4 +148,4 @@ def main():
|
|
| 146 |
|
| 147 |
|
| 148 |
if __name__ == "__main__":
|
| 149 |
-
|
|
|
|
| 4 |
from workflows.courses.expectation_revision import ExpectationRevision
|
| 5 |
|
| 6 |
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def course_suggester_main():
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
[data-testid="stAppViewContainer"]{
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
+
course_suggester_main()
|
ui/course_lessons_extractor.py
DELETED
|
@@ -1,74 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import asyncio
|
| 3 |
-
from contextlib import contextmanager
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
-
from workflows.courses.lessons_extractor import LessonsExtractor
|
| 6 |
-
from streamlit_extras.capture import stdout
|
| 7 |
-
load_dotenv()
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
@contextmanager
|
| 11 |
-
def setup_event_loop():
|
| 12 |
-
loop = asyncio.new_event_loop()
|
| 13 |
-
asyncio.set_event_loop(loop)
|
| 14 |
-
try:
|
| 15 |
-
yield loop
|
| 16 |
-
finally:
|
| 17 |
-
loop.close()
|
| 18 |
-
asyncio.set_event_loop(None)
|
| 19 |
-
|
| 20 |
-
def main():
|
| 21 |
-
page_bg_img = '''
|
| 22 |
-
<style>
|
| 23 |
-
[data-testid="stAppViewContainer"]{
|
| 24 |
-
background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg");
|
| 25 |
-
background-size:cover;
|
| 26 |
-
}
|
| 27 |
-
[data-testid="stHeader"]{
|
| 28 |
-
background: rgba(0,0,0,0);
|
| 29 |
-
}
|
| 30 |
-
[data-testid="stToolbar"]{
|
| 31 |
-
right: 2rem;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
</style>
|
| 36 |
-
'''
|
| 37 |
-
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 38 |
-
st.markdown("<div class='container'>", unsafe_allow_html=True)
|
| 39 |
-
|
| 40 |
-
st.markdown(
|
| 41 |
-
"""
|
| 42 |
-
<div class="centered">
|
| 43 |
-
<p class="title">Course Lesson Extractor</p>
|
| 44 |
-
</div>
|
| 45 |
-
""",
|
| 46 |
-
unsafe_allow_html=True
|
| 47 |
-
)
|
| 48 |
-
course_url = st.text_area('Enter the URL for the course:',
|
| 49 |
-
"https://www.coursera.org/learn/google-data-analytics-capstone?specialization=google-data-analytics",
|
| 50 |
-
key='course_url', help='Enter course you want to learn')
|
| 51 |
-
|
| 52 |
-
if st.button("Get Lessons"):
|
| 53 |
-
with st.status(
|
| 54 |
-
"π€ **Extracting Lessons...**", state="running", expanded=True
|
| 55 |
-
) as status:
|
| 56 |
-
with st.container(height=500, border=False):
|
| 57 |
-
log_container = st.empty()
|
| 58 |
-
with stdout(log_container.code, terminator=""):
|
| 59 |
-
with setup_event_loop() as loop:
|
| 60 |
-
extractor = LessonsExtractor()
|
| 61 |
-
inputs = {"course_url": course_url}
|
| 62 |
-
results = extractor.kickoff(inputs=inputs)["lessons"]
|
| 63 |
-
status.update(
|
| 64 |
-
label="β
Extracted Lessons!",
|
| 65 |
-
state="complete",
|
| 66 |
-
expanded=False,
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
for idx, lesson in enumerate(results):
|
| 70 |
-
st.markdown(f"#### Lessons {idx}: {lesson['name']}")
|
| 71 |
-
st.markdown(f"Concpets: {', '.join(lesson['concepts'])}")
|
| 72 |
-
|
| 73 |
-
if __name__ == "__main__":
|
| 74 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui/research_paper.py
DELETED
|
@@ -1,142 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from workflows.research_article_suggester import RecentArticleSuggester
|
| 3 |
-
from streamlit_extras.capture import stdout
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def main():
|
| 8 |
-
|
| 9 |
-
st.markdown(
|
| 10 |
-
"""
|
| 11 |
-
<style>
|
| 12 |
-
# .main {
|
| 13 |
-
# background-color: #f5f5f5;
|
| 14 |
-
# padding: 20px;
|
| 15 |
-
# border-radius: 10px;
|
| 16 |
-
# }
|
| 17 |
-
.centered {
|
| 18 |
-
display: flex;
|
| 19 |
-
flex-direction: column;
|
| 20 |
-
align-items: center;
|
| 21 |
-
justify-content: center;
|
| 22 |
-
text-align: center;
|
| 23 |
-
}
|
| 24 |
-
.title {
|
| 25 |
-
font-family: 'Helvetica', sans-serif;
|
| 26 |
-
font-weight: bold;
|
| 27 |
-
font-size: 36px;
|
| 28 |
-
color: #1f77b4;
|
| 29 |
-
}
|
| 30 |
-
.description {
|
| 31 |
-
font-family: 'Helvetica', sans-serif;
|
| 32 |
-
font-size: 18px;
|
| 33 |
-
color: #333333;
|
| 34 |
-
margin-top: 10px;
|
| 35 |
-
}
|
| 36 |
-
.subheader {
|
| 37 |
-
font-family: 'Helvetica', sans-serif;
|
| 38 |
-
font-weight: bold;
|
| 39 |
-
font-size: 24px;
|
| 40 |
-
color: #ff7f0e;
|
| 41 |
-
margin-top: 20px;
|
| 42 |
-
}
|
| 43 |
-
.element {
|
| 44 |
-
background-color: #ffffff;
|
| 45 |
-
padding: 1rem;
|
| 46 |
-
border-radius: 8px;
|
| 47 |
-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
| 48 |
-
margin-bottom: 1rem;
|
| 49 |
-
}
|
| 50 |
-
.element h3 {
|
| 51 |
-
font-size: 24px;
|
| 52 |
-
color: #1f77b4;
|
| 53 |
-
margin-bottom: 0.5rem;
|
| 54 |
-
text-transform: uppercase;
|
| 55 |
-
padding :10px;
|
| 56 |
-
|
| 57 |
-
}
|
| 58 |
-
.element ul {
|
| 59 |
-
list-style-type: none;
|
| 60 |
-
padding: 0;
|
| 61 |
-
margin: 0;
|
| 62 |
-
}
|
| 63 |
-
.element li {
|
| 64 |
-
font-size: 16px;
|
| 65 |
-
color: #333333;
|
| 66 |
-
margin-bottom: 0.5rem;
|
| 67 |
-
}
|
| 68 |
-
.element li b {
|
| 69 |
-
font-size: 22px;
|
| 70 |
-
}
|
| 71 |
-
[data-testid="stAppViewContainer"]{
|
| 72 |
-
background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg");
|
| 73 |
-
background-size:cover;
|
| 74 |
-
}
|
| 75 |
-
[data-testid="stHeader"]{
|
| 76 |
-
background: rgba(0,0,0,0);
|
| 77 |
-
}
|
| 78 |
-
[data-testid="stToolbar"]{
|
| 79 |
-
right: 2rem;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
</style>
|
| 83 |
-
""",
|
| 84 |
-
unsafe_allow_html=True
|
| 85 |
-
)
|
| 86 |
-
|
| 87 |
-
st.markdown("<div class='container'>", unsafe_allow_html=True)
|
| 88 |
-
|
| 89 |
-
st.markdown(
|
| 90 |
-
"""
|
| 91 |
-
<div class="centered">
|
| 92 |
-
<p class="title">Recent Article Suggester</p>
|
| 93 |
-
<p class="description">Discover recent articles based on your topic of interest using advanced AI.</p>
|
| 94 |
-
</div>
|
| 95 |
-
""",
|
| 96 |
-
unsafe_allow_html=True
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
st.sidebar.markdown("<p class='sidebar-header'>Search for the papers you are interested in:</p>", unsafe_allow_html=True)
|
| 100 |
-
topic = st.sidebar.text_input('Enter a topic:', 'GenAI', key='topic_input', help='Enter a topic of interest')
|
| 101 |
-
|
| 102 |
-
if st.sidebar.button('Get Suggestions'):
|
| 103 |
-
|
| 104 |
-
with st.status(
|
| 105 |
-
"π€ **Agents at work...**", state="running", expanded=True
|
| 106 |
-
) as status:
|
| 107 |
-
with st.container(height=500, border=False):
|
| 108 |
-
log_container = st.empty()
|
| 109 |
-
with stdout(log_container.code, terminator=""):
|
| 110 |
-
suggester = RecentArticleSuggester()
|
| 111 |
-
inputs = {"topic": topic}
|
| 112 |
-
results = suggester.kickoff(inputs=inputs)
|
| 113 |
-
status.update(
|
| 114 |
-
label="β
Articles are Ready for Reading!",
|
| 115 |
-
state="complete",
|
| 116 |
-
expanded=False,
|
| 117 |
-
)
|
| 118 |
-
|
| 119 |
-
st.subheader("", anchor=False, divider="rainbow")
|
| 120 |
-
|
| 121 |
-
if results is None:
|
| 122 |
-
st.markdown('No articles found.', unsafe_allow_html=True)
|
| 123 |
-
else:
|
| 124 |
-
|
| 125 |
-
st.markdown('<p class="subheader">Results:</p>', unsafe_allow_html=True)
|
| 126 |
-
|
| 127 |
-
for element in results:
|
| 128 |
-
st.markdown(
|
| 129 |
-
f"""
|
| 130 |
-
<div class="element">
|
| 131 |
-
<h3><a href="{element['url']}" target="_blank">{element['title']}</a></h3>
|
| 132 |
-
<ul>
|
| 133 |
-
{"".join(f"<li style='font-size: 20px;'><b>{key.capitalize()}:</b> {value}</li>" for key, value in element.items() if key != "title")}
|
| 134 |
-
</ul>
|
| 135 |
-
</div>
|
| 136 |
-
""",
|
| 137 |
-
unsafe_allow_html=True
|
| 138 |
-
)
|
| 139 |
-
if st.sidebar.button("β Back to Main Page"):
|
| 140 |
-
st.session_state.page = "main"
|
| 141 |
-
if __name__ == "__main__":
|
| 142 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui/til_feedback.py
CHANGED
|
@@ -6,6 +6,7 @@ from langsmith import Client
|
|
| 6 |
from workflows.utils.feedback import Feedback
|
| 7 |
|
| 8 |
load_dotenv()
|
|
|
|
| 9 |
def feedback_main():
|
| 10 |
|
| 11 |
page_bg_img = '''
|
|
@@ -125,5 +126,6 @@ def clear_feedback_state(results):
|
|
| 125 |
if key.endswith("_feedback_given"):
|
| 126 |
st.session_state[key] = False
|
| 127 |
|
|
|
|
| 128 |
if __name__ == "__main__":
|
| 129 |
feedback_main()
|
|
|
|
| 6 |
from workflows.utils.feedback import Feedback
|
| 7 |
|
| 8 |
load_dotenv()
|
| 9 |
+
|
| 10 |
def feedback_main():
|
| 11 |
|
| 12 |
page_bg_img = '''
|
|
|
|
| 126 |
if key.endswith("_feedback_given"):
|
| 127 |
st.session_state[key] = False
|
| 128 |
|
| 129 |
+
|
| 130 |
if __name__ == "__main__":
|
| 131 |
feedback_main()
|
ui_main.py
CHANGED
|
@@ -1,46 +1,33 @@
|
|
| 1 |
from dotenv import load_dotenv
|
| 2 |
from streamlit_extras.stylable_container import stylable_container
|
| 3 |
-
from ui.
|
| 4 |
-
from ui.
|
| 5 |
-
from ui.research_paper import main as research_article_suggester_main
|
| 6 |
-
from ui.til_feedback import feedback_main
|
| 7 |
-
from ui.course_learn_suggest_expectations import main as course_suggester_main
|
| 8 |
import math
|
| 9 |
import streamlit as st
|
| 10 |
import subprocess
|
|
|
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
| 14 |
subprocess.run(["playwright", "install", "chromium"])
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
def load_css(file_name):
|
| 18 |
with open(file_name) as f:
|
| 19 |
return f.read()
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
def main():
|
| 23 |
-
|
| 24 |
-
if 'page' not in st.session_state:
|
| 25 |
-
st.session_state.page = "main"
|
| 26 |
-
|
| 27 |
-
if st.session_state.page == "main":
|
| 28 |
-
show_main_page()
|
| 29 |
-
elif st.session_state.page == "article_recommendor":
|
| 30 |
-
article_recommendor_main()
|
| 31 |
-
elif st.session_state.page == "research_article_suggester":
|
| 32 |
-
research_article_suggester_main()
|
| 33 |
-
elif st.session_state.page == "feedback":
|
| 34 |
-
feedback_main()
|
| 35 |
-
elif st.session_state.page == "lessons_extractor":
|
| 36 |
-
lessons_extractor_main()
|
| 37 |
-
elif st.session_state.page == "course_suggester":
|
| 38 |
-
course_suggester_main()
|
| 39 |
|
| 40 |
|
| 41 |
def show_main_page():
|
| 42 |
-
st.set_page_config(page_title='Growthy AI Workflows',
|
| 43 |
-
page_icon='π°', layout="wide")
|
| 44 |
page_bg_img = '''
|
| 45 |
<style>
|
| 46 |
[data-testid="stAppViewContainer"]{
|
|
@@ -53,96 +40,116 @@ def show_main_page():
|
|
| 53 |
[data-testid="stToolbar"]{
|
| 54 |
right: 2rem;
|
| 55 |
}
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
</style>
|
| 59 |
'''
|
| 60 |
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 61 |
-
|
| 62 |
css = load_css("ui/main.css")
|
| 63 |
|
| 64 |
st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
|
| 65 |
|
| 66 |
-
st.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>',
|
| 67 |
-
unsafe_allow_html=True)
|
| 68 |
st.markdown("---")
|
| 69 |
|
| 70 |
card_info = [
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
{"title": "Course Lesson Extractor", "description": "Extract lessons for a given course",
|
| 76 |
-
"key": "lessons_extractor", "image": "https://agent.ai/icons/business-analyst.svg"},
|
| 77 |
-
{"title": "Article Recommender", "description": "Discover articles tailored to your interests.",
|
| 78 |
-
"key": "article_recommendor", "image": "https://agent.ai/icons/robot.svg"},
|
| 79 |
-
{"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.",
|
| 80 |
-
"key": "research_article_suggester", "image": "https://agent.ai/icons/data.svg"},
|
| 81 |
-
|
| 82 |
-
]
|
| 83 |
|
| 84 |
num_cols = 3
|
| 85 |
num_rows = math.ceil(len(card_info) / num_cols)
|
| 86 |
|
| 87 |
-
col1, col2, col3 = st.columns([1,
|
| 88 |
|
| 89 |
with col2:
|
| 90 |
for row in range(num_rows):
|
| 91 |
-
cols = st.columns(num_cols)
|
| 92 |
for col in range(num_cols):
|
| 93 |
index = row * num_cols + col
|
| 94 |
if index < len(card_info):
|
| 95 |
card = card_info[index]
|
| 96 |
with cols[col]:
|
| 97 |
-
with
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
""", unsafe_allow_html=True
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
if __name__ == '__main__':
|
| 148 |
-
main()
|
|
|
|
| 1 |
from dotenv import load_dotenv
|
| 2 |
from streamlit_extras.stylable_container import stylable_container
|
| 3 |
+
from ui.til_feedback import feedback_main
|
| 4 |
+
from ui.course_learn_suggest_expectations import course_suggester_main
|
|
|
|
|
|
|
|
|
|
| 5 |
import math
|
| 6 |
import streamlit as st
|
| 7 |
import subprocess
|
| 8 |
+
import streamlit_router as sr
|
| 9 |
|
| 10 |
load_dotenv()
|
| 11 |
|
| 12 |
subprocess.run(["playwright", "install", "chromium"])
|
| 13 |
|
| 14 |
+
st.set_page_config(page_title='Growthy AI Workflows', page_icon='π°',layout="wide")
|
| 15 |
|
| 16 |
def load_css(file_name):
|
| 17 |
with open(file_name) as f:
|
| 18 |
return f.read()
|
| 19 |
|
| 20 |
+
def common_sidebar():
|
| 21 |
+
st.sidebar.markdown("# Sidebar Navigation")
|
| 22 |
+
st.sidebar.markdown("---")
|
| 23 |
+
st.sidebar.markdown("### Pages")
|
| 24 |
+
st.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))
|
| 25 |
+
st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))
|
| 26 |
+
st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_suggester_main_wrapper")))
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def show_main_page():
|
|
|
|
|
|
|
| 31 |
page_bg_img = '''
|
| 32 |
<style>
|
| 33 |
[data-testid="stAppViewContainer"]{
|
|
|
|
| 40 |
[data-testid="stToolbar"]{
|
| 41 |
right: 2rem;
|
| 42 |
}
|
| 43 |
+
[data-testid="column"] {
|
| 44 |
+
text-align: center;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
</style>
|
| 48 |
'''
|
| 49 |
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 50 |
+
|
| 51 |
css = load_css("ui/main.css")
|
| 52 |
|
| 53 |
st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
|
| 54 |
|
| 55 |
+
st.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>', unsafe_allow_html=True)
|
|
|
|
| 56 |
st.markdown("---")
|
| 57 |
|
| 58 |
card_info = [
|
| 59 |
+
{"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "π"},
|
| 60 |
+
{"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper", "image": "π"},
|
| 61 |
+
|
| 62 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
num_cols = 3
|
| 65 |
num_rows = math.ceil(len(card_info) / num_cols)
|
| 66 |
|
| 67 |
+
col1, col2, col3 = st.columns([1,8,1])
|
| 68 |
|
| 69 |
with col2:
|
| 70 |
for row in range(num_rows):
|
| 71 |
+
cols = st.columns(num_cols,gap="large")
|
| 72 |
for col in range(num_cols):
|
| 73 |
index = row * num_cols + col
|
| 74 |
if index < len(card_info):
|
| 75 |
card = card_info[index]
|
| 76 |
with cols[col]:
|
| 77 |
+
with st.container(height=280,border=False):
|
| 78 |
+
with stylable_container(
|
| 79 |
+
key="inside_container_with_border",
|
| 80 |
+
|
| 81 |
+
css_styles="""
|
| 82 |
+
{
|
| 83 |
+
background-color: #e9eaec;
|
| 84 |
+
border-radius: 10px;
|
| 85 |
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
|
| 86 |
+
# padding:10px;
|
| 87 |
+
display: flex;
|
| 88 |
+
flex-direction: row;
|
| 89 |
+
flex-wrap: wrap;
|
| 90 |
+
align-items: center;
|
| 91 |
+
justify-content: center;
|
| 92 |
+
border: 1px solid #C0C0C0;
|
| 93 |
+
text-align: center;
|
| 94 |
+
margin-bottom: 10px;
|
| 95 |
+
} """,
|
| 96 |
+
):
|
| 97 |
+
st.markdown(
|
| 98 |
+
f"""
|
| 99 |
+
<div style="
|
| 100 |
+
font-size: 4rem;
|
| 101 |
+
margin-bottom: 10px;
|
| 102 |
+
">
|
| 103 |
+
{card['image']}
|
| 104 |
+
</div>
|
| 105 |
+
""", unsafe_allow_html=True
|
| 106 |
+
)
|
| 107 |
+
st.markdown(
|
| 108 |
+
f"""
|
| 109 |
+
<div style=" display: flex; flex-wrap:wrap; flex-direction: column; text-align: center; justify-content: center; align-items: center">
|
| 110 |
+
<span style="font-weight:900; font-size: 24px;"> {card["title"]}</span>
|
| 111 |
+
<p class="styled-description">{card["description"]}</p>
|
| 112 |
+
</div>
|
| 113 |
+
""", unsafe_allow_html=True
|
| 114 |
+
)
|
| 115 |
+
if st.button("Explore", key=card["key"]):
|
| 116 |
+
router.redirect(*router.build(f"{card['key']}"))
|
| 117 |
+
|
| 118 |
+
st.markdown(
|
| 119 |
+
"""
|
| 120 |
+
<style>
|
| 121 |
+
# [data-testid="stImage"] img {
|
| 122 |
+
# padding:10px;
|
| 123 |
+
# height: 100px;
|
| 124 |
+
# width: 100px;
|
| 125 |
+
# border-radius: 50%;
|
| 126 |
+
# border: 2px solid white;
|
| 127 |
+
|
| 128 |
+
# }
|
| 129 |
+
|
| 130 |
+
[data-testid="column"] div[data-testid="column"]{
|
| 131 |
+
margin: 10px;
|
| 132 |
+
}
|
| 133 |
+
</style>
|
| 134 |
""", unsafe_allow_html=True
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def feedback_main_wrapper():
|
| 139 |
+
common_sidebar()
|
| 140 |
+
feedback_main()
|
| 141 |
+
|
| 142 |
+
def course_suggester_main_wrapper():
|
| 143 |
+
common_sidebar()
|
| 144 |
+
course_suggester_main()
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
router = sr.StreamlitRouter()
|
| 149 |
+
|
| 150 |
+
router.register(show_main_page, '/')
|
| 151 |
+
router.register(feedback_main_wrapper, '/feedback', methods=['GET'])
|
| 152 |
+
router.register(course_suggester_main_wrapper, '/course_suggester')
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
router.serve()
|
|
|
|
|
|
|
|
|
|
|
|