Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
-
from learning_platform import
|
| 4 |
import asyncio
|
| 5 |
import nest_asyncio
|
| 6 |
from datetime import datetime
|
|
|
|
|
|
|
| 7 |
|
| 8 |
nest_asyncio.apply()
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Page config
|
| 11 |
st.set_page_config(page_title="MicroGuru", page_icon="🎓", layout="wide")
|
| 12 |
|
|
@@ -86,7 +94,7 @@ api_key = os.environ.get('OPENAI_API_KEY')
|
|
| 86 |
if not api_key:
|
| 87 |
st.error("⚠️ OpenAI API key not found.")
|
| 88 |
st.stop()
|
| 89 |
-
platform =
|
| 90 |
|
| 91 |
def display_agent_logs():
|
| 92 |
"""Display agent activity logs in sidebar"""
|
|
@@ -200,7 +208,7 @@ def create_new_course():
|
|
| 200 |
with st.spinner('Our AI agents are crafting your personalized course...'):
|
| 201 |
try:
|
| 202 |
async def create_course():
|
| 203 |
-
return await platform.create_course(topic, difficulty)
|
| 204 |
|
| 205 |
path = asyncio.run(create_course())
|
| 206 |
st.session_state.learning_path = path
|
|
@@ -266,7 +274,7 @@ def display_current_course():
|
|
| 266 |
else:
|
| 267 |
with st.spinner("Generating next module..."):
|
| 268 |
asyncio.run(
|
| 269 |
-
platform.
|
| 270 |
)
|
| 271 |
st.rerun()
|
| 272 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
+
from learning_platform import EnhancedCourseBuilder
|
| 4 |
import asyncio
|
| 5 |
import nest_asyncio
|
| 6 |
from datetime import datetime
|
| 7 |
+
from sqlalchemy.orm import sessionmaker
|
| 8 |
+
from models import create_engine
|
| 9 |
|
| 10 |
nest_asyncio.apply()
|
| 11 |
|
| 12 |
+
# Database setup
|
| 13 |
+
db_url = os.getenv('DATABASE_URL', 'sqlite:///learning_platform.db')
|
| 14 |
+
engine = create_engine(db_url)
|
| 15 |
+
Session = sessionmaker(bind=engine)
|
| 16 |
+
db_session = Session()
|
| 17 |
+
|
| 18 |
# Page config
|
| 19 |
st.set_page_config(page_title="MicroGuru", page_icon="🎓", layout="wide")
|
| 20 |
|
|
|
|
| 94 |
if not api_key:
|
| 95 |
st.error("⚠️ OpenAI API key not found.")
|
| 96 |
st.stop()
|
| 97 |
+
platform = EnhancedCourseBuilder(api_key, db_session)
|
| 98 |
|
| 99 |
def display_agent_logs():
|
| 100 |
"""Display agent activity logs in sidebar"""
|
|
|
|
| 208 |
with st.spinner('Our AI agents are crafting your personalized course...'):
|
| 209 |
try:
|
| 210 |
async def create_course():
|
| 211 |
+
return await platform.create_course(topic, difficulty, user_id=1)
|
| 212 |
|
| 213 |
path = asyncio.run(create_course())
|
| 214 |
st.session_state.learning_path = path
|
|
|
|
| 274 |
else:
|
| 275 |
with st.spinner("Generating next module..."):
|
| 276 |
asyncio.run(
|
| 277 |
+
platform.generate_module_content(module_id=path.modules[next_idx].id)
|
| 278 |
)
|
| 279 |
st.rerun()
|
| 280 |
|