calmgoose commited on
Commit
981455c
Β·
1 Parent(s): 3ba989b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -93,7 +93,7 @@ def get_answer(question):
93
  for item in unique_sources:
94
  sources_string += str(item) + ", "
95
 
96
- return result["result"] + "\n\n" + "From pages: " + sources_string
97
 
98
 
99
  # From here down is all the StreamLit UI.
@@ -102,7 +102,7 @@ st.title("Talk2Book: 1984")
102
  st.markdown("#### Have a conversaion with 1984 by George Orwell πŸ™Š")
103
 
104
  with st.sidebar:
105
- api_key = st.text_input(label = "Paste your OpenAI API key here", type = "password")
106
  os.environ["OPENAI_API_KEY"] = api_key
107
 
108
  st.info("This isn't saved πŸ™ˆ")
@@ -123,12 +123,12 @@ ask = st.button("Ask")
123
  if ask:
124
 
125
  if os.environ["OPENAI_API_KEY"] is None:
126
- st.text("Paste your OpenAI API key to get started")
127
  else:
128
  output = get_answer(question=user_input)
129
 
130
- st.session_state.past.append(user_input)
131
- st.session_state.generated.append(output)
132
 
133
  if st.session_state["generated"]:
134
 
 
93
  for item in unique_sources:
94
  sources_string += str(item) + ", "
95
 
96
+ return result["result"] + "\n\n" + " - From pages: " + sources_string
97
 
98
 
99
  # From here down is all the StreamLit UI.
 
102
  st.markdown("#### Have a conversaion with 1984 by George Orwell πŸ™Š")
103
 
104
  with st.sidebar:
105
+ api_key = st.text_input(label = "Paste your OpenAI API key here to get started", type = "password")
106
  os.environ["OPENAI_API_KEY"] = api_key
107
 
108
  st.info("This isn't saved πŸ™ˆ")
 
123
  if ask:
124
 
125
  if os.environ["OPENAI_API_KEY"] is None:
126
+ output = "Whoops looks like you forgot your API key buddy"
127
  else:
128
  output = get_answer(question=user_input)
129
 
130
+ st.session_state.past.append(user_input)
131
+ st.session_state.generated.append(output)
132
 
133
  if st.session_state["generated"]:
134