Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,21 @@
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
import uuid
|
| 4 |
-
from typing import List, Tuple, Optional, Union
|
|
|
|
| 5 |
|
| 6 |
import google.generativeai as genai
|
| 7 |
import gradio as gr
|
| 8 |
from PIL import Image
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
# Obtener la clave API desde las variables de entorno
|
| 13 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 14 |
|
|
|
|
|
|
|
| 15 |
TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
|
| 16 |
SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
|
| 17 |
DES = """
|
|
@@ -58,7 +62,6 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
|
|
| 58 |
return "", chatbot
|
| 59 |
|
| 60 |
def bot(
|
| 61 |
-
google_key: str,
|
| 62 |
files: Optional[List[str]],
|
| 63 |
temperature: float,
|
| 64 |
max_output_tokens: int,
|
|
@@ -67,10 +70,10 @@ def bot(
|
|
| 67 |
top_p: float,
|
| 68 |
chatbot: CHAT_HISTORY
|
| 69 |
):
|
| 70 |
-
if not
|
| 71 |
raise ValueError("GOOGLE_API_KEY is not set.")
|
| 72 |
-
|
| 73 |
-
genai.configure(api_key=
|
| 74 |
generation_config = genai.types.GenerationConfig(
|
| 75 |
temperature=temperature,
|
| 76 |
max_output_tokens=max_output_tokens,
|
|
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
import uuid
|
| 4 |
+
from typing import List, Tuple, Optional, Dict, Union
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
|
| 7 |
import google.generativeai as genai
|
| 8 |
import gradio as gr
|
| 9 |
from PIL import Image
|
| 10 |
|
| 11 |
+
# Cargar las variables de entorno desde el archivo .env
|
| 12 |
+
load_dotenv()
|
| 13 |
|
| 14 |
# Obtener la clave API desde las variables de entorno
|
| 15 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 16 |
|
| 17 |
+
print("google-generativeai:", genai.__version__)
|
| 18 |
+
|
| 19 |
TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
|
| 20 |
SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
|
| 21 |
DES = """
|
|
|
|
| 62 |
return "", chatbot
|
| 63 |
|
| 64 |
def bot(
|
|
|
|
| 65 |
files: Optional[List[str]],
|
| 66 |
temperature: float,
|
| 67 |
max_output_tokens: int,
|
|
|
|
| 70 |
top_p: float,
|
| 71 |
chatbot: CHAT_HISTORY
|
| 72 |
):
|
| 73 |
+
if not GOOGLE_API_KEY:
|
| 74 |
raise ValueError("GOOGLE_API_KEY is not set.")
|
| 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,
|