acpotts commited on
Commit
3fc4557
·
1 Parent(s): 337cc6c

try...except with os.environ

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -50,7 +50,10 @@ class RetrievalAugmentedQAPipeline:
50
  return {"response": generate_response(), "context": context_list}
51
 
52
  # text_splitter = RecursiveCharacterTextSplitter()
53
- api_key = os.getenv("OPENAI_API_KEY")
 
 
 
54
  text_splitter = SemanticChunker(OpenAIEmbeddings(api_key=api_key), breakpoint_threshold_type="standard_deviation")
55
 
56
  def process_text_file(file: AskFileResponse):
 
50
  return {"response": generate_response(), "context": context_list}
51
 
52
  # text_splitter = RecursiveCharacterTextSplitter()
53
+ try:
54
+ api_key = os.environ["OPENAI_API_KEY"]
55
+ except KeyError:
56
+ print("Environment variable OPENAI_API_KEY not found")
57
  text_splitter = SemanticChunker(OpenAIEmbeddings(api_key=api_key), breakpoint_threshold_type="standard_deviation")
58
 
59
  def process_text_file(file: AskFileResponse):