yonikremer commited on
Commit
d029425
1 Parent(s): 5ecef5e

improved error-handling

Browse files
Files changed (1) hide show
  1. prompt_engeneering.py +9 -2
prompt_engeneering.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from dataclasses import dataclass
2
  from datetime import datetime
3
  from typing import Generator, Dict, List
@@ -15,12 +16,18 @@ INSTRUCTIONS = "Instructions: " \
15
 
16
  def get_google_api_key():
17
  """Returns the Google API key from streamlit's secrets"""
18
- return secrets["google_search_api_key"]
 
 
 
19
 
20
 
21
  def get_google_cse_id():
22
  """Returns the Google CSE ID from streamlit's secrets"""
23
- return secrets["google_cse_id"]
 
 
 
24
 
25
 
26
  def google_search(search_term, **kwargs) -> list:
 
1
+ import os
2
  from dataclasses import dataclass
3
  from datetime import datetime
4
  from typing import Generator, Dict, List
 
16
 
17
  def get_google_api_key():
18
  """Returns the Google API key from streamlit's secrets"""
19
+ try:
20
+ return secrets["google_search_api_key"]
21
+ except FileNotFoundError:
22
+ return os.environ["google_search_api_key"]
23
 
24
 
25
  def get_google_cse_id():
26
  """Returns the Google CSE ID from streamlit's secrets"""
27
+ try:
28
+ return secrets["google_cse_id"]
29
+ except FileNotFoundError:
30
+ return os.environ["google_cse_id"]
31
 
32
 
33
  def google_search(search_term, **kwargs) -> list: