eagle0504 commited on
Commit
e7bf46e
Β·
verified Β·
1 Parent(s): 28217e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -39,8 +39,8 @@ with st.sidebar:
39
  2. **Response**: The app will display a response from GPT-4o.
40
  3. **Chat History**: Previous conversations will be shown on the app.
41
  ### Credits:
42
- - **Developer**: [Yiqiao Yin](https://www.y-yin.io/) | [App URL](https://huggingface.co/spaces/eagle0504/meta-llama) | [LinkedIn](https://www.linkedin.com/in/yiqiaoyin/) | [YouTube](https://youtube.com/YiqiaoYin/)
43
- Enjoy chatting with Meta's Llama3 model!
44
  """)
45
 
46
  # Example:
@@ -53,7 +53,6 @@ with st.sidebar:
53
  # Add a button to clear the session state
54
  if st.button("Clear Session"):
55
  st.session_state.messages = []
56
- st.session_state["history"] = [{"role": "system", "content": "You are a helpful assistant."}]
57
  st.experimental_rerun()
58
 
59
 
@@ -73,9 +72,6 @@ for message in st.session_state.messages:
73
  st.markdown(message["content"])
74
 
75
  # React to user input
76
- if "history" not in st.session_state:
77
- st.session_state["history"] = [{"role": "system", "content": "You are a helpful assistant."}]
78
-
79
  if prompt := st.chat_input("πŸ˜‰ Ask any question or feel free to use the examples provided in the left sidebar."):
80
 
81
  # Display user message in chat message container
@@ -86,7 +82,7 @@ if prompt := st.chat_input("πŸ˜‰ Ask any question or feel free to use the exampl
86
 
87
  # API Call
88
  bot = ChatBot()
89
- bot.history = st.session_state.messages # Update history from messages
90
  response = bot.generate_response(prompt)
91
 
92
  # Display assistant response in chat message container
 
39
  2. **Response**: The app will display a response from GPT-4o.
40
  3. **Chat History**: Previous conversations will be shown on the app.
41
  ### Credits:
42
+ - **Developer**: [Yiqiao Yin](https://www.y-yin.io/) | [App URL](https://huggingface.co/spaces/eagle0504/gpt-4o-demo) | [LinkedIn](https://www.linkedin.com/in/yiqiaoyin/) | [YouTube](https://youtube.com/YiqiaoYin/)
43
+ Enjoy chatting with OpenAI's GPT-4o model!
44
  """)
45
 
46
  # Example:
 
53
  # Add a button to clear the session state
54
  if st.button("Clear Session"):
55
  st.session_state.messages = []
 
56
  st.experimental_rerun()
57
 
58
 
 
72
  st.markdown(message["content"])
73
 
74
  # React to user input
 
 
 
75
  if prompt := st.chat_input("πŸ˜‰ Ask any question or feel free to use the examples provided in the left sidebar."):
76
 
77
  # Display user message in chat message container
 
82
 
83
  # API Call
84
  bot = ChatBot()
85
+ bot.history = st.session_state.messages.copy() # Update history from messages
86
  response = bot.generate_response(prompt)
87
 
88
  # Display assistant response in chat message container