ajwthompson commited on
Commit
603178d
·
1 Parent(s): 40cb81b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -17,11 +17,17 @@ class ChatWrapper:
17
  def __call__(
18
  self, inp: str, history: Optional[Tuple[str, str]]
19
  ):
 
 
 
 
 
 
 
 
 
20
 
21
-
22
- chain = get_chain(vectorstore)
23
- """Execute the chat functionality."""
24
- os.environ["OPENAI_API_KEY"] = api_key
25
  self.lock.acquire()
26
  api_key = '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'
27
  chain = set_openai_api_key(api_key)
 
17
  def __call__(
18
  self, inp: str, history: Optional[Tuple[str, str]]
19
  ):
20
+ def set_openai_api_key(api_key: str):
21
+ """Set the api key and return chain.
22
+ If no api_key, then None is returned.
23
+ """
24
+ if api_key:
25
+ os.environ["OPENAI_API_KEY"] = api_key
26
+ chain = get_chain(vectorstore)
27
+ os.environ["OPENAI_API_KEY"] = ""
28
+ return chain
29
 
30
+
 
 
 
31
  self.lock.acquire()
32
  api_key = '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'
33
  chain = set_openai_api_key(api_key)