Joanna30 commited on
Commit
5400370
·
verified ·
1 Parent(s): ef90d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -5,7 +5,6 @@ from langchain.chains import ConversationChain
5
  from langchain.chains.conversation.memory import ConversationBufferMemory, ConversationSummaryMemory
6
 
7
  # Step 1: Set up Google API key
8
- # Retrieve API key from secrets (ensure you set this up in Streamlit secrets)
9
  google_api_key = st.secrets["google_api_key"]
10
 
11
  # Step 2: Initialize Session State Variables
@@ -27,7 +26,10 @@ st.session_state['API_Key'] = st.sidebar.text_input("Enter your Google API key",
27
  # Summarization button
28
  summarise_button = st.sidebar.button("Summarise the conversation", key="summarise")
29
  if summarise_button:
30
- summarise_placeholder = st.sidebar.write("Nice chatting with you my friend <3️:\n\n" + str(st.session_state['conversation'].memory.buffer))
 
 
 
31
 
32
  # Step 4: Define the getresponse function using Google's Gemini
33
  def getresponse(userInput, api_key):
 
5
  from langchain.chains.conversation.memory import ConversationBufferMemory, ConversationSummaryMemory
6
 
7
  # Step 1: Set up Google API key
 
8
  google_api_key = st.secrets["google_api_key"]
9
 
10
  # Step 2: Initialize Session State Variables
 
26
  # Summarization button
27
  summarise_button = st.sidebar.button("Summarise the conversation", key="summarise")
28
  if summarise_button:
29
+ if st.session_state['conversation'] is not None: # Check if conversation is initialized
30
+ summarise_placeholder = st.sidebar.write("Nice chatting with you my friend <3️:\n\n" + str(st.session_state['conversation'].memory.buffer))
31
+ else:
32
+ st.sidebar.write("No conversation history to summarize.")
33
 
34
  # Step 4: Define the getresponse function using Google's Gemini
35
  def getresponse(userInput, api_key):