Phaneendrabayi commited on
Commit
a029893
·
verified ·
1 Parent(s): 31956ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -33,13 +33,22 @@ def chat_with_ai(user, message):
33
  memory.chat_memory.add_message(msg)
34
  memory.chat_memory.add_message(HumanMessage(content=message))
35
 
36
- response = model.invoke([SystemMessage(content="You are a helpful AI agent.")] + memory.chat_memory.messages)
 
 
 
 
 
 
 
 
 
37
  parsed_response = output_parser.parse(response.content.strip())
38
  save_chat(history_store, message, parsed_response)
39
  return parsed_response
40
 
41
  # Streamlit UI
42
- st.title("Chat with AI (Gemini + LangChain)")
43
 
44
  # User session management
45
  if "user" not in st.session_state:
 
33
  memory.chat_memory.add_message(msg)
34
  memory.chat_memory.add_message(HumanMessage(content=message))
35
 
36
+ response = model.invoke([SystemMessage(content=f"""
37
+ You are a data science tutor. Answer ONLY data science-related questions.
38
+ If the user asks something unrelated, politely decline.
39
+ Keep the conversation aware using memory.
40
+
41
+ Conversation history: {conversation_history}
42
+
43
+ User: {user_input}
44
+ """)] + memory.chat_memory.messages)
45
+
46
  parsed_response = output_parser.parse(response.content.strip())
47
  save_chat(history_store, message, parsed_response)
48
  return parsed_response
49
 
50
  # Streamlit UI
51
+ st.title("Data Science Tutor")
52
 
53
  # User session management
54
  if "user" not in st.session_state: