diff --git a/backend/main.py b/backend/main.py index 88d6461..32a06e6 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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) \ No newline at end of file + 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 \ No newline at end of file diff --git a/frontend/app.py b/frontend/app.py index e9aea08..253e3a8 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -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: @@ -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 🚀