Harshal Vhatkar
commited on
Commit
·
d3c8852
1
Parent(s):
1eb8c2b
add python course and fix some bugs
Browse files- app.py +8 -8
- session_page.py +21 -2
app.py
CHANGED
@@ -135,9 +135,9 @@ def login_form():
|
|
135 |
# Role selection at the top
|
136 |
user_type = st.selectbox(
|
137 |
"Please select your Role",
|
138 |
-
["
|
139 |
)
|
140 |
-
|
141 |
# Username/email and password stacked vertically
|
142 |
username = st.text_input("Username or Email")
|
143 |
password = st.text_input("Password", type="password")
|
@@ -180,7 +180,7 @@ def get_courses(username, user_type):
|
|
180 |
# courses = list(courses_cursor1) + list(courses_cursor2)
|
181 |
return list(courses)
|
182 |
elif user_type == "faculty":
|
183 |
-
faculty = faculty_collection.find_one({"full_name": username})
|
184 |
if faculty:
|
185 |
course_ids = [
|
186 |
course["course_id"] for course in faculty.get("courses_taught", [])
|
@@ -224,7 +224,7 @@ def create_session(new_session, course_id):
|
|
224 |
last_session_id = int(last_session_id[1:])
|
225 |
new_session_id = last_session_id + 1
|
226 |
new_session["session_id"] = "S" + str(new_session_id)
|
227 |
-
|
228 |
{"course_id": new_session["course_id"]},
|
229 |
{"$push": {"sessions": new_session}},
|
230 |
)
|
@@ -250,7 +250,7 @@ def create_session_form(course_id):
|
|
250 |
|
251 |
new_session_id = None
|
252 |
# Generate new session ID
|
253 |
-
course =
|
254 |
if course and "sessions" in course and course["sessions"]:
|
255 |
last_session_id = max(
|
256 |
int(session["session_id"][1:]) for session in course["sessions"]
|
@@ -281,7 +281,7 @@ def create_session_form(course_id):
|
|
281 |
"assignments": [],
|
282 |
},
|
283 |
}
|
284 |
-
|
285 |
{"course_id": course_id}, {"$push": {"sessions": new_session}}
|
286 |
)
|
287 |
st.success("Session created successfully!")
|
@@ -553,9 +553,9 @@ def register_page():
|
|
553 |
# Select user type
|
554 |
st.session_state.user_type = st.selectbox(
|
555 |
"Please select your Role",
|
556 |
-
["
|
557 |
)
|
558 |
-
user_type = st.session_state.user_type
|
559 |
|
560 |
with st.form("register_form"):
|
561 |
col1, col2 = st.columns(2)
|
|
|
135 |
# Role selection at the top
|
136 |
user_type = st.selectbox(
|
137 |
"Please select your Role",
|
138 |
+
["Student", "Faculty", "Research Assistant", "Analyst"]
|
139 |
)
|
140 |
+
user_type = user_type.lower().replace(" ", "_")
|
141 |
# Username/email and password stacked vertically
|
142 |
username = st.text_input("Username or Email")
|
143 |
password = st.text_input("Password", type="password")
|
|
|
180 |
# courses = list(courses_cursor1) + list(courses_cursor2)
|
181 |
return list(courses)
|
182 |
elif user_type == "faculty":
|
183 |
+
faculty = faculty_collection.find_one({"$or": [{"full_name": username}, {"username": username}]})
|
184 |
if faculty:
|
185 |
course_ids = [
|
186 |
course["course_id"] for course in faculty.get("courses_taught", [])
|
|
|
224 |
last_session_id = int(last_session_id[1:])
|
225 |
new_session_id = last_session_id + 1
|
226 |
new_session["session_id"] = "S" + str(new_session_id)
|
227 |
+
courses_collection.update_one(
|
228 |
{"course_id": new_session["course_id"]},
|
229 |
{"$push": {"sessions": new_session}},
|
230 |
)
|
|
|
250 |
|
251 |
new_session_id = None
|
252 |
# Generate new session ID
|
253 |
+
course = courses_collection.find_one({"course_id": course_id})
|
254 |
if course and "sessions" in course and course["sessions"]:
|
255 |
last_session_id = max(
|
256 |
int(session["session_id"][1:]) for session in course["sessions"]
|
|
|
281 |
"assignments": [],
|
282 |
},
|
283 |
}
|
284 |
+
courses_collection.update_one(
|
285 |
{"course_id": course_id}, {"$push": {"sessions": new_session}}
|
286 |
)
|
287 |
st.success("Session created successfully!")
|
|
|
553 |
# Select user type
|
554 |
st.session_state.user_type = st.selectbox(
|
555 |
"Please select your Role",
|
556 |
+
["Student", "Faculty", "Research Assistant", "Analyst"]
|
557 |
)
|
558 |
+
user_type = st.session_state.user_type.lower().replace(" ", "_")
|
559 |
|
560 |
with st.form("register_form"):
|
561 |
col1, col2 = st.columns(2)
|
session_page.py
CHANGED
@@ -3,7 +3,7 @@ import json
|
|
3 |
import random
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
-
from datetime import datetime
|
7 |
from youtube_transcript_api import YouTubeTranscriptApi
|
8 |
from utils.helpers import display_progress_bar, create_notification, format_datetime
|
9 |
from file_upload_vectorize import upload_resource, extract_text_from_file, create_vector_store, resources_collection, model, assignment_submit
|
@@ -23,6 +23,7 @@ from pre_class_analytics2 import NovaScholarAnalytics
|
|
23 |
import openai
|
24 |
from openai import OpenAI
|
25 |
import google.generativeai as genai
|
|
|
26 |
from goals2 import GoalAnalyzer
|
27 |
from openai import OpenAI
|
28 |
import asyncio
|
@@ -34,6 +35,7 @@ import streamlit.components.v1 as components
|
|
34 |
from live_chat_feature import display_live_chat_interface
|
35 |
from code_playground import display_code_playground
|
36 |
|
|
|
37 |
load_dotenv()
|
38 |
MONGO_URI = os.getenv('MONGO_URI')
|
39 |
PERPLEXITY_API_KEY = os.getenv('PERPLEXITY_KEY')
|
@@ -47,6 +49,11 @@ assignment_evaluation_collection = db["assignment_evaluation"]
|
|
47 |
subjective_tests_collection = db["subjective_tests"]
|
48 |
synoptic_store_collection = db["synoptic_store"]
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
def get_current_user():
|
51 |
if 'current_user' not in st.session_state:
|
52 |
return None
|
@@ -334,7 +341,6 @@ def display_preclass_content(session, student_id, course_id):
|
|
334 |
"timestamp": datetime.utcnow()
|
335 |
}
|
336 |
st.session_state.messages.append(new_message)
|
337 |
-
|
338 |
# Update database
|
339 |
try:
|
340 |
chat_history_collection.update_one(
|
@@ -700,6 +706,19 @@ def upload_preclass_materials(session_id, course_id):
|
|
700 |
- URL: [{resource['url']}]({resource['url']})
|
701 |
""")
|
702 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
703 |
def extract_external_content(url, content_type):
|
704 |
"""Extract content from external resources based on their type"""
|
705 |
try:
|
|
|
3 |
import random
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
+
from datetime import datetime, timedelta
|
7 |
from youtube_transcript_api import YouTubeTranscriptApi
|
8 |
from utils.helpers import display_progress_bar, create_notification, format_datetime
|
9 |
from file_upload_vectorize import upload_resource, extract_text_from_file, create_vector_store, resources_collection, model, assignment_submit
|
|
|
23 |
import openai
|
24 |
from openai import OpenAI
|
25 |
import google.generativeai as genai
|
26 |
+
from google.generativeai import caching
|
27 |
from goals2 import GoalAnalyzer
|
28 |
from openai import OpenAI
|
29 |
import asyncio
|
|
|
35 |
from live_chat_feature import display_live_chat_interface
|
36 |
from code_playground import display_code_playground
|
37 |
|
38 |
+
# Load environment variables
|
39 |
load_dotenv()
|
40 |
MONGO_URI = os.getenv('MONGO_URI')
|
41 |
PERPLEXITY_API_KEY = os.getenv('PERPLEXITY_KEY')
|
|
|
49 |
subjective_tests_collection = db["subjective_tests"]
|
50 |
synoptic_store_collection = db["synoptic_store"]
|
51 |
|
52 |
+
|
53 |
+
# for implementing Context Caching:
|
54 |
+
# PROJECT_ID = "novascholar-446709"
|
55 |
+
# vertexai.init(project=PROJECT_ID, location="us-west4")
|
56 |
+
|
57 |
def get_current_user():
|
58 |
if 'current_user' not in st.session_state:
|
59 |
return None
|
|
|
341 |
"timestamp": datetime.utcnow()
|
342 |
}
|
343 |
st.session_state.messages.append(new_message)
|
|
|
344 |
# Update database
|
345 |
try:
|
346 |
chat_history_collection.update_one(
|
|
|
706 |
- URL: [{resource['url']}]({resource['url']})
|
707 |
""")
|
708 |
|
709 |
+
# Display pre-class materials
|
710 |
+
# Group resources by their types
|
711 |
+
grouped_resources = defaultdict(list)
|
712 |
+
materials = resources_collection.find({"session_id": session_id})
|
713 |
+
for material in materials:
|
714 |
+
grouped_resources[material['material_type']].append(material)
|
715 |
+
|
716 |
+
# Display grouped resources
|
717 |
+
for material_type, resources in grouped_resources.items():
|
718 |
+
st.markdown(f"##### {material_type.capitalize()} Resources")
|
719 |
+
for material in resources:
|
720 |
+
st.markdown(f"- **{material['file_name']}** ({material['file_type']})")
|
721 |
+
|
722 |
def extract_external_content(url, content_type):
|
723 |
"""Extract content from external resources based on their type"""
|
724 |
try:
|