SkalskiP commited on
Commit
ea30afb
1 Parent(s): fc7864f

Add support for GOOGLE_API_KEY environment variables.

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import time
2
  from typing import List, Tuple, Optional
3
 
@@ -25,6 +26,9 @@ AVATAR_IMAGES = (
25
  )
26
 
27
 
 
 
 
28
  def preprocess_stop_sequences(stop_sequences: str) -> Optional[List[str]]:
29
  if not stop_sequences:
30
  return None
@@ -46,6 +50,7 @@ def bot(
46
  top_p: float,
47
  chatbot: List[Tuple[str, str]]
48
  ):
 
49
  if not google_key:
50
  raise ValueError(
51
  "GOOGLE_API_KEY is not set. "
@@ -93,6 +98,7 @@ google_key_component = gr.Textbox(
93
  type="password",
94
  placeholder="...",
95
  info="You have to provide your own GOOGLE_API_KEY for this app to function properly",
 
96
  )
97
 
98
  image_prompt_component = gr.Image(type="pil", label="Image")
 
1
+ import os
2
  import time
3
  from typing import List, Tuple, Optional
4
 
 
26
  )
27
 
28
 
29
+ GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
30
+
31
+
32
  def preprocess_stop_sequences(stop_sequences: str) -> Optional[List[str]]:
33
  if not stop_sequences:
34
  return None
 
50
  top_p: float,
51
  chatbot: List[Tuple[str, str]]
52
  ):
53
+ google_key = google_key if google_key else GOOGLE_API_KEY
54
  if not google_key:
55
  raise ValueError(
56
  "GOOGLE_API_KEY is not set. "
 
98
  type="password",
99
  placeholder="...",
100
  info="You have to provide your own GOOGLE_API_KEY for this app to function properly",
101
+ visible=GOOGLE_API_KEY is None
102
  )
103
 
104
  image_prompt_component = gr.Image(type="pil", label="Image")