Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,94 +75,53 @@ def main():
|
|
| 75 |
|
| 76 |
tabs = st.tabs(["π Learn", "π¬ Chat", "π My Courses"])
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
st.error(f"Error: {str(e)}")
|
| 97 |
-
else:
|
| 98 |
-
path = st.session_state.learning_path
|
| 99 |
-
current_module = path.modules[st.session_state.current_module]
|
| 100 |
-
|
| 101 |
-
st.markdown(f"### π {current_module.title}")
|
| 102 |
-
|
| 103 |
-
if not current_module.is_complete:
|
| 104 |
-
st.info("π Module content is being generated...")
|
| 105 |
-
st.spinner("Please wait...")
|
| 106 |
else:
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
col1, col2 = st.columns(2)
|
| 111 |
-
with col1:
|
| 112 |
-
if st.session_state.current_module > 0:
|
| 113 |
-
if st.button("β¬
οΈ Previous Module"):
|
| 114 |
-
st.session_state.current_module -= 1
|
| 115 |
-
st.rerun()
|
| 116 |
-
|
| 117 |
-
with col2:
|
| 118 |
-
next_idx = st.session_state.current_module + 1
|
| 119 |
-
if next_idx < len(path.modules):
|
| 120 |
-
if path.modules[next_idx].is_complete:
|
| 121 |
-
if st.button("Next Module β‘οΈ"):
|
| 122 |
-
st.session_state.current_module = next_idx
|
| 123 |
-
st.rerun()
|
| 124 |
-
else:
|
| 125 |
-
st.info("β³ Next module is being prepared...")
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
with tabs[1]:
|
| 129 |
-
if st.session_state.learning_path:
|
| 130 |
-
st.markdown("### π¬ Chat with MicroGuru")
|
| 131 |
|
| 132 |
-
|
| 133 |
-
st.markdown(f'''
|
| 134 |
-
<div class="chat-message {'user-message' if msg['role'] == 'user' else 'assistant-message'}">
|
| 135 |
-
{msg['content']}
|
| 136 |
-
</div>
|
| 137 |
-
''', unsafe_allow_html=True)
|
| 138 |
|
| 139 |
-
if
|
| 140 |
-
st.
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
with tabs[2]:
|
| 163 |
-
st.markdown("### My Learning Journey")
|
| 164 |
-
if not st.session_state.courses['in_progress']:
|
| 165 |
-
st.info("No courses yet. Start learning!")
|
| 166 |
|
| 167 |
if __name__ == "__main__":
|
| 168 |
main()
|
|
|
|
| 75 |
|
| 76 |
tabs = st.tabs(["π Learn", "π¬ Chat", "π My Courses"])
|
| 77 |
|
| 78 |
+
with tabs[0]:
|
| 79 |
+
if not st.session_state.learning_path:
|
| 80 |
+
st.markdown("### π Start Learning")
|
| 81 |
+
with st.form("course_generator"):
|
| 82 |
+
topic = st.text_input("What would you like to learn?")
|
| 83 |
+
difficulty = st.selectbox("Level", ["beginner", "intermediate", "advanced"])
|
| 84 |
+
if st.form_submit_button("Create Course π―"):
|
| 85 |
+
with st.spinner('Creating your personalized course...'):
|
| 86 |
+
try:
|
| 87 |
+
async def create_and_set_course():
|
| 88 |
+
path = await platform.create_course(topic, difficulty)
|
| 89 |
+
st.session_state.learning_path = path
|
| 90 |
+
return path
|
| 91 |
+
path = asyncio.run(create_and_set_course())
|
| 92 |
+
st.success("First module ready! Start learning while others generate.")
|
| 93 |
+
st.rerun()
|
| 94 |
+
except Exception as e:
|
| 95 |
+
st.error(f"Error: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
else:
|
| 97 |
+
path = st.session_state.learning_path
|
| 98 |
+
current_module = path.modules[st.session_state.current_module]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
+
st.markdown(f"### π {current_module.title}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
if not current_module.is_complete:
|
| 103 |
+
st.info("π Module content is being generated...")
|
| 104 |
+
st.spinner("Please wait...")
|
| 105 |
+
else:
|
| 106 |
+
for section in current_module.sections:
|
| 107 |
+
display_section(section)
|
| 108 |
+
|
| 109 |
+
col1, col2 = st.columns(2)
|
| 110 |
+
with col1:
|
| 111 |
+
if st.session_state.current_module > 0:
|
| 112 |
+
if st.button("β¬
οΈ Previous Module"):
|
| 113 |
+
st.session_state.current_module -= 1
|
| 114 |
+
st.rerun()
|
| 115 |
+
|
| 116 |
+
with col2:
|
| 117 |
+
next_idx = st.session_state.current_module + 1
|
| 118 |
+
if next_idx < len(path.modules):
|
| 119 |
+
if path.modules[next_idx].is_complete:
|
| 120 |
+
if st.button("Next Module β‘οΈ"):
|
| 121 |
+
st.session_state.current_module = next_idx
|
| 122 |
+
st.rerun()
|
| 123 |
+
else:
|
| 124 |
+
st.info("β³ Next module is being prepared...")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
| 127 |
main()
|