DrishtiSharma commited on
Commit
b78869b
·
verified ·
1 Parent(s): 389e02f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -20,13 +20,14 @@ with st.sidebar:
20
  openai_key = os.getenv("OPENAI_API_KEY", "")
21
  serpapi_key = os.getenv("SERP_API_KEY", "")
22
 
23
- # Check if keys are set
24
  if not openai_key:
25
  openai_key = st.sidebar.text_input("Missing: OpenAI API Key (OPENAI_API_KEY)", "")
26
  if not serpapi_key:
27
  serpapi_key = st.sidebar.text_input("Missing: SERP API Key (SERPAPI_KEY)", "")
28
 
29
- else:
 
30
  # Main content
31
  if st.button("Find Similar Patents"):
32
  try:
@@ -74,3 +75,5 @@ else:
74
  st.error(f"Key error encountered: {e}")
75
  except Exception as e:
76
  st.error(f"An error occurred: {e}")
 
 
 
20
  openai_key = os.getenv("OPENAI_API_KEY", "")
21
  serpapi_key = os.getenv("SERP_API_KEY", "")
22
 
23
+ # Check if keys are set or allow the user to provide them
24
  if not openai_key:
25
  openai_key = st.sidebar.text_input("Missing: OpenAI API Key (OPENAI_API_KEY)", "")
26
  if not serpapi_key:
27
  serpapi_key = st.sidebar.text_input("Missing: SERP API Key (SERPAPI_KEY)", "")
28
 
29
+ # Proceed only if both keys are set
30
+ if openai_key and serpapi_key:
31
  # Main content
32
  if st.button("Find Similar Patents"):
33
  try:
 
75
  st.error(f"Key error encountered: {e}")
76
  except Exception as e:
77
  st.error(f"An error occurred: {e}")
78
+ else:
79
+ st.error("Please provide both OpenAI and SERP API keys in the sidebar to proceed.")