IAMTFRMZA commited on
Commit
555e200
·
verified ·
1 Parent(s): cad0524

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -23,19 +23,13 @@ if not st.session_state.authenticated:
23
  if st.button("Login"):
24
  if username == "[email protected]" and password == "Pass.123":
25
  st.session_state.authenticated = True
26
- st.success("Login successful! Please refresh the page or continue below.")
27
- else:
28
- st.error("Invalid username or password.")
29
-
30
- # Show chat interface only if logged in
31
- if st.session_state.authenticated:
32
- # Sidebar with clear chat button and chat log link
33
  with st.sidebar:
34
  if st.button("🧹 Clear Chat"):
35
  st.session_state.messages = []
36
  st.success("Chat history cleared.")
37
- st.markdown("---")
38
- st.markdown("**Chat logs are saved locally in `chat_logs.txt`.**")
39
 
40
  # Initialize OpenAI client
41
  client = OpenAI(api_key=openai_key)
@@ -51,7 +45,7 @@ if st.session_state.authenticated:
51
  role, content = message["role"], message["content"]
52
  st.chat_message(role).write(content)
53
 
54
- # Helper function to save chat transcripts
55
  def save_transcript(messages):
56
  with open("chat_logs.txt", "a") as f:
57
  f.write(f"\n--- New Chat ({datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}) ---\n")
@@ -97,7 +91,7 @@ if st.session_state.authenticated:
97
  st.chat_message("assistant").write(assistant_message)
98
  st.session_state.messages.append({"role": "assistant", "content": assistant_message})
99
 
100
- # Save conversation transcript every interaction
101
  save_transcript(st.session_state.messages)
102
 
103
  except Exception as e:
 
23
  if st.button("Login"):
24
  if username == "[email protected]" and password == "Pass.123":
25
  st.session_state.authenticated = True
26
+ st.success("Login successful!")
27
+ else:
28
+ # Sidebar with clear chat button
 
 
 
 
29
  with st.sidebar:
30
  if st.button("🧹 Clear Chat"):
31
  st.session_state.messages = []
32
  st.success("Chat history cleared.")
 
 
33
 
34
  # Initialize OpenAI client
35
  client = OpenAI(api_key=openai_key)
 
45
  role, content = message["role"], message["content"]
46
  st.chat_message(role).write(content)
47
 
48
+ # Helper function to save chat transcripts (not displayed, backend only)
49
  def save_transcript(messages):
50
  with open("chat_logs.txt", "a") as f:
51
  f.write(f"\n--- New Chat ({datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}) ---\n")
 
91
  st.chat_message("assistant").write(assistant_message)
92
  st.session_state.messages.append({"role": "assistant", "content": assistant_message})
93
 
94
+ # Save conversation transcript silently
95
  save_transcript(st.session_state.messages)
96
 
97
  except Exception as e: