Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,11 @@ from PIL import Image
|
|
9 |
|
10 |
print("google-generativeai:", genai.__version__)
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
|
15 |
SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
|
@@ -57,7 +61,6 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
|
|
57 |
return "", chatbot
|
58 |
|
59 |
def bot(
|
60 |
-
google_key: str,
|
61 |
files: Optional[List[str]],
|
62 |
temperature: float,
|
63 |
max_output_tokens: int,
|
@@ -66,10 +69,11 @@ def bot(
|
|
66 |
top_p: float,
|
67 |
chatbot: CHAT_HISTORY
|
68 |
):
|
69 |
-
|
70 |
-
|
|
|
71 |
|
72 |
-
genai.configure(api_key=
|
73 |
generation_config = genai.types.GenerationConfig(
|
74 |
temperature=temperature,
|
75 |
max_output_tokens=max_output_tokens,
|
@@ -92,14 +96,6 @@ def bot(
|
|
92 |
time.sleep(0.01)
|
93 |
yield chatbot
|
94 |
|
95 |
-
google_key_component = gr.Textbox(
|
96 |
-
label="GOOGLE API KEY",
|
97 |
-
value="",
|
98 |
-
type="password",
|
99 |
-
placeholder="...",
|
100 |
-
info="Please provide your own GOOGLE_API_KEY for this app",
|
101 |
-
visible=GOOGLE_API_KEY is None
|
102 |
-
)
|
103 |
chatbot_component = gr.Chatbot(
|
104 |
label='Gemini',
|
105 |
bubble_full_width=False,
|
|
|
9 |
|
10 |
print("google-generativeai:", genai.__version__)
|
11 |
|
12 |
+
# Cargar las variables de entorno
|
13 |
+
load_dotenv()
|
14 |
+
|
15 |
+
# Configurar la API de Google usando la clave desde las variables de entorno
|
16 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
17 |
|
18 |
TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
|
19 |
SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
|
|
|
61 |
return "", chatbot
|
62 |
|
63 |
def bot(
|
|
|
64 |
files: Optional[List[str]],
|
65 |
temperature: float,
|
66 |
max_output_tokens: int,
|
|
|
69 |
top_p: float,
|
70 |
chatbot: CHAT_HISTORY
|
71 |
):
|
72 |
+
# La clave de API ya está configurada automáticamente a través de las variables de entorno
|
73 |
+
if not GOOGLE_API_KEY:
|
74 |
+
raise ValueError("GOOGLE_API_KEY is not set in environment variables.")
|
75 |
|
76 |
+
genai.configure(api_key=GOOGLE_API_KEY)
|
77 |
generation_config = genai.types.GenerationConfig(
|
78 |
temperature=temperature,
|
79 |
max_output_tokens=max_output_tokens,
|
|
|
96 |
time.sleep(0.01)
|
97 |
yield chatbot
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
chatbot_component = gr.Chatbot(
|
100 |
label='Gemini',
|
101 |
bubble_full_width=False,
|