Spaces:
Sleeping
Sleeping
try...except with os.environ
Browse files
app.py
CHANGED
@@ -50,7 +50,10 @@ class RetrievalAugmentedQAPipeline:
|
|
50 |
return {"response": generate_response(), "context": context_list}
|
51 |
|
52 |
# text_splitter = RecursiveCharacterTextSplitter()
|
53 |
-
|
|
|
|
|
|
|
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):
|