Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,20 @@ def run_tts():
gpt4_model = TextModel(model_name="gpt-4-1106-preview")
response_text = gpt4_model.complete(input_text)
# Call the tts function with the formatted string
tts(response_text)
tts(response_text)

def recommend_video_link(question, context):
client = OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "Based on the video titles below, recommend the most relevant video for the question. If the question can't be answered based on the titles, then return empty string. Note: Only provide the link to the video and no additional text.\n\n" + context},
{"role": "user", "content": f"Question: {question}\nAnswer:"}
],
temperature=0,
max_tokens=100,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
)
return response.choices[0].message.content
7 changes: 6 additions & 1 deletion frontend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
VOICE_TESTING = "backend/speech.mp3"
LOGO = "frontend/testing_data/logo.jpeg"
FAVICON = "frontend/testing_data/logo.png"
VIDEO_LINK = "videos.csv"

# Initialize state variables if not already present
if "student_images_paths" not in st.session_state:
Expand Down Expand Up @@ -166,6 +167,8 @@
audio_bytes = audio_file.read()
st.audio(audio_bytes, format="audio/mp3", start_time=0)

df = pd.read_csv(VIDEO_LINK)
context = read_video_csv(df)
results = "🌟 Here are the recommended questions for improvement! Let's dive in and explore 🚀<ul>"
with open(CSV_PATH, mode="r", encoding="utf-8") as csv_file:
# Create a CSV reader object from the file object
Expand All @@ -177,7 +180,9 @@
for row in csv_reader:
question_id = row["question_id"]
question = row["question"]
results += f"<li><strong>Question {question_id}:</strong> {question}</li>"
video = recommend_video_link(question, context)

results += f"<li><strong>Question {question_id}:</strong> {question}. Ref: {video} </li>"

results += "</ul>✨ Keep up the great work, and remember, every question is a step towards mastery! 📚"

Expand Down
9 changes: 9 additions & 0 deletions frontend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ def display_images(file_paths, default_image_path, title):
else:
# Display default image if no images are found
st.image(default_image_path, caption="Default Image", width=500)

def read_video_csv(df):
# Prepare the context for GPT based on video names and their links
context = "Based on the following video titles and their links:\n"
for _, row in df.iterrows():
question = row['question']
video_link = row['link']
context += f"- {question}: {video_link}\n"
return context
5 changes: 5 additions & 0 deletions videos.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
question,link
Solve for x: 2x + 5 = 15,https://www.youtube.com/watch?v=pOeotbDbC7I
Find the roots of the quadratic equation: x^2 - 5x + 6 = 0 ,https://www.youtube.com/watch?v=ri5PJ7b6594
"If f(x) = 3x^2 - 2x + 1, find f(2) ",https://www.youtube.com/watch?v=UzeLsa38wQI
Simplify the expression 2x^2 - 8 / x - 2 ,https://www.youtube.com/watch?v=M-AqHlSQwcI