charesz commited on
Commit
1cb1036
·
verified ·
1 Parent(s): 60612b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -9,8 +9,9 @@ gemini_api_key = st.secrets.get("GEN_API_KEY", "")
9
  # -------------------
10
  # Page Configuration
11
  # -------------------
12
- st.set_page_config(page_title="Your AI Buddy", layout="wide")
13
- st.title("💡 Need answers? Just type below!")
 
14
 
15
  # -------------------
16
  # Gemini Setup
@@ -48,11 +49,11 @@ if "gemini_chat" not in st.session_state or st.session_state.get("model") != mod
48
  st.stop()
49
 
50
  # -------------------
51
- # System Prompt
52
  # -------------------
53
  system_prompt = st.sidebar.text_area(
54
  "System Prompt",
55
- "You are a helpful AI assistant. Provide concise and accurate answers."
56
  )
57
 
58
  # -------------------
@@ -66,7 +67,7 @@ if st.sidebar.button("Reset Conversation"):
66
  st.session_state.messages = []
67
  gemini_model = genai.GenerativeModel(model)
68
  st.session_state.gemini_chat = gemini_model.start_chat(history=[])
69
- st.rerun()
70
 
71
  # -------------------
72
  # Display Chat Messages
@@ -78,13 +79,15 @@ for msg in st.session_state.messages:
78
  # -------------------
79
  # User Input
80
  # -------------------
81
- if user_input := st.chat_input("Type your message..."):
 
 
82
  # Show user message
83
  st.chat_message("user").markdown(user_input)
84
  st.session_state.messages.append({"role": "user", "content": user_input})
85
 
86
  try:
87
- with st.spinner("Gemini is thinking..."):
88
  # Prepend system prompt for context
89
  full_input = f"{system_prompt}\n\nUser: {user_input}"
90
  resp = st.session_state.gemini_chat.send_message(full_input)
@@ -96,4 +99,4 @@ if user_input := st.chat_input("Type your message..."):
96
  st.markdown(bot_text)
97
 
98
  st.session_state.messages.append({"role": "assistant", "content": bot_text})
99
- st.rerun()
 
9
  # -------------------
10
  # Page Configuration
11
  # -------------------
12
+ st.set_page_config(page_title="Academic Tutor AI", layout="wide")
13
+ st.title("📚 Academic Tutor AI")
14
+ st.write("Ask questions about your courses and get clear explanations, examples, and study tips.")
15
 
16
  # -------------------
17
  # Gemini Setup
 
49
  st.stop()
50
 
51
  # -------------------
52
+ # System Prompt for Academic Tutor
53
  # -------------------
54
  system_prompt = st.sidebar.text_area(
55
  "System Prompt",
56
+ "You are a friendly academic tutor for college students. Provide clear explanations, examples, and study tips. Encourage understanding rather than just giving answers."
57
  )
58
 
59
  # -------------------
 
67
  st.session_state.messages = []
68
  gemini_model = genai.GenerativeModel(model)
69
  st.session_state.gemini_chat = gemini_model.start_chat(history=[])
70
+ st.experimental_rerun()
71
 
72
  # -------------------
73
  # Display Chat Messages
 
79
  # -------------------
80
  # User Input
81
  # -------------------
82
+ user_input = st.chat_input("Type your academic question here (e.g., 'Explain Bayes' Theorem with an example.')")
83
+
84
+ if user_input:
85
  # Show user message
86
  st.chat_message("user").markdown(user_input)
87
  st.session_state.messages.append({"role": "user", "content": user_input})
88
 
89
  try:
90
+ with st.spinner("🤔 Thinking..."):
91
  # Prepend system prompt for context
92
  full_input = f"{system_prompt}\n\nUser: {user_input}"
93
  resp = st.session_state.gemini_chat.send_message(full_input)
 
99
  st.markdown(bot_text)
100
 
101
  st.session_state.messages.append({"role": "assistant", "content": bot_text})
102
+ st.experimental_rerun()