Update app.py
Browse files
app.py
CHANGED
@@ -21,18 +21,21 @@ retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
|
|
21 |
|
22 |
# Define a prompt template for course recommendations
|
23 |
prompt_template = """
|
24 |
-
You are an AI course recommendation system. Your task is to
|
|
|
|
|
|
|
|
|
25 |
|
26 |
Summarized Chat History:
|
27 |
{chat_history}
|
28 |
|
29 |
User's Current Query: {question}
|
30 |
|
31 |
-
|
32 |
-
{context}
|
33 |
|
34 |
-
|
35 |
-
1. A detailed explanation of how the recommended courses
|
36 |
2. A summary of each recommended course, highlighting:
|
37 |
- The specific skills and knowledge the user will gain (from "What You Will Learn")
|
38 |
- Key topics covered in the syllabus
|
@@ -42,9 +45,7 @@ Please provide a personalized course recommendation. Your response should includ
|
|
42 |
4. Any additional advice or suggestions for the user's learning journey, based on the syllabus progression and their conversation history.
|
43 |
5. Provide the course URLs for easy access.
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
Remember to be encouraging and supportive in your recommendation, and relate your suggestions to any preferences or constraints the user has mentioned in previous messages.
|
48 |
|
49 |
Recommendation:
|
50 |
"""
|
@@ -121,10 +122,12 @@ if prompt := st.chat_input("What are you looking to learn?"):
|
|
121 |
with st.chat_message("assistant"):
|
122 |
response = qa_chain({"question": prompt})
|
123 |
response_text = response["answer"]
|
124 |
-
|
125 |
# Simulate streaming response
|
|
|
126 |
for word in response_text.split():
|
127 |
-
|
|
|
128 |
time.sleep(0.05) # Delay for effect
|
129 |
|
130 |
# Add assistant response to chat history
|
|
|
21 |
|
22 |
# Define a prompt template for course recommendations
|
23 |
prompt_template = """
|
24 |
+
You are an AI course recommendation system. Your task is to assist users by engaging them in conversation and providing course recommendations only when they explicitly ask for it.
|
25 |
+
|
26 |
+
If the user does not indicate interest in receiving course recommendations, focus on engaging them in conversation and understanding their interests.
|
27 |
+
|
28 |
+
Consider the summarized chat history to provide more relevant and personalized recommendations when requested.
|
29 |
|
30 |
Summarized Chat History:
|
31 |
{chat_history}
|
32 |
|
33 |
User's Current Query: {question}
|
34 |
|
35 |
+
If the user has asked for course recommendations, provide a list of relevant courses based on their interests and goals, emphasizing how the courses match the learning outcomes and syllabus content.
|
|
|
36 |
|
37 |
+
Your response should include:
|
38 |
+
1. A detailed explanation of how the recommended courses align with the user's interests and previous queries, focusing on the "What You Will Learn" section and the syllabus content.
|
39 |
2. A summary of each recommended course, highlighting:
|
40 |
- The specific skills and knowledge the user will gain (from "What You Will Learn")
|
41 |
- Key topics covered in the syllabus
|
|
|
45 |
4. Any additional advice or suggestions for the user's learning journey, based on the syllabus progression and their conversation history.
|
46 |
5. Provide the course URLs for easy access.
|
47 |
|
48 |
+
If the user has not explicitly requested course recommendations, respond in a conversational manner, encouraging them to share more about their interests or asking follow-up questions to better understand their needs.
|
|
|
|
|
49 |
|
50 |
Recommendation:
|
51 |
"""
|
|
|
122 |
with st.chat_message("assistant"):
|
123 |
response = qa_chain({"question": prompt})
|
124 |
response_text = response["answer"]
|
125 |
+
|
126 |
# Simulate streaming response
|
127 |
+
full_response = ""
|
128 |
for word in response_text.split():
|
129 |
+
full_response += word + " "
|
130 |
+
st.markdown(full_response.strip(), unsafe_allow_html=True) # Display the accumulated response
|
131 |
time.sleep(0.05) # Delay for effect
|
132 |
|
133 |
# Add assistant response to chat history
|