eagle0504 commited on
Commit
6dca666
·
verified ·
1 Parent(s): e7bf46e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import streamlit as st
2
  import os
3
  from openai import OpenAI
@@ -25,6 +27,12 @@ class ChatBot:
25
  return self.history
26
 
27
 
 
 
 
 
 
 
28
  st.set_page_config(layout="wide")
29
  st.title("OpenAI GPT-4o 🤖")
30
 
@@ -49,6 +57,14 @@ with st.sidebar:
49
  st.success("Example: How to conduct an AI experiment?")
50
  st.success("Example: Write a tensorflow flow code with a 3-layer neural network model.")
51
 
 
 
 
 
 
 
 
 
52
 
53
  # Add a button to clear the session state
54
  if st.button("Clear Session"):
@@ -78,6 +94,7 @@ if prompt := st.chat_input("😉 Ask any question or feel free to use the exampl
78
  st.chat_message("user").markdown(prompt)
79
 
80
  # Add user message to chat history
 
81
  st.session_state.messages.append({"role": "user", "content": prompt})
82
 
83
  # API Call
 
1
+ from datetime import datetime
2
+
3
  import streamlit as st
4
  import os
5
  from openai import OpenAI
 
27
  return self.history
28
 
29
 
30
+ # Credit: Time
31
+ def current_year():
32
+ now = datetime.now()
33
+ return now.year
34
+
35
+
36
  st.set_page_config(layout="wide")
37
  st.title("OpenAI GPT-4o 🤖")
38
 
 
57
  st.success("Example: How to conduct an AI experiment?")
58
  st.success("Example: Write a tensorflow flow code with a 3-layer neural network model.")
59
 
60
+ # Credit:
61
+ current_year = current_year() # This will print the current year
62
+ st.markdown(
63
+ f"""
64
+ <h6 style='text-align: left;'>Copyright © 2010-{current_year} Present Yiqiao Yin</h6>
65
+ """,
66
+ unsafe_allow_html=True,
67
+ )
68
 
69
  # Add a button to clear the session state
70
  if st.button("Clear Session"):
 
94
  st.chat_message("user").markdown(prompt)
95
 
96
  # Add user message to chat history
97
+ st.session_state.messages.append({"role": "system", content: f"You are a helpful assistant. Year now is {current_year}"})
98
  st.session_state.messages.append({"role": "user", "content": prompt})
99
 
100
  # API Call