doncamilom commited on
Commit
7fdd738
·
1 Parent(s): 0e493b2

workaround for paperqa requiring global apikey

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -59,7 +59,6 @@ tool_list.columns = ['Tool', 'Description']
59
 
60
  def on_api_key_change():
61
  api_key = ss.get('api_key') or os.getenv('OPENAI_API_KEY')
62
- os.environ['OPENAI_API_KEY'] = ss.get('api_key')
63
  # Check if key is valid
64
  if not oai_key_isvalid(api_key):
65
  st.write("Please input a valid OpenAI API key.")
@@ -148,4 +147,9 @@ with st.sidebar:
148
 
149
  # Execute agent on user input
150
  if user_input := st.chat_input():
 
 
 
151
  run_prompt(user_input)
 
 
 
59
 
60
  def on_api_key_change():
61
  api_key = ss.get('api_key') or os.getenv('OPENAI_API_KEY')
 
62
  # Check if key is valid
63
  if not oai_key_isvalid(api_key):
64
  st.write("Please input a valid OpenAI API key.")
 
147
 
148
  # Execute agent on user input
149
  if user_input := st.chat_input():
150
+ if ss.get('api_key') is not None:
151
+ os.environ['OPENAI_API_KEY'] = ss.get('api_key')
152
+
153
  run_prompt(user_input)
154
+ os.environ['OPENAI_API_KEY'] = 'none'
155
+