Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,8 @@ import tempfile
|
|
| 7 |
# Configure the Gemini API
|
| 8 |
GOOGLE_API_KEY = os.getenv("gemini_api") # Ensure your API key is set
|
| 9 |
client = genai.Client(api_key=GOOGLE_API_KEY)
|
| 10 |
-
|
|
|
|
| 11 |
def transcribe_audio(audio_path):
|
| 12 |
"""
|
| 13 |
Transcribe the audio file using the Gemini API.
|
|
@@ -42,7 +43,7 @@ def chat_with_gemini(user_input, history):
|
|
| 42 |
"""
|
| 43 |
if history is None or not isinstance(history, list): # Ensure history is initialized
|
| 44 |
history = []
|
| 45 |
-
|
| 46 |
# Initialize or continue conversation
|
| 47 |
if chat is None:
|
| 48 |
chat = client.chats.create(model="gemini-2.0-flash") # Initialize chat once
|
|
|
|
| 7 |
# Configure the Gemini API
|
| 8 |
GOOGLE_API_KEY = os.getenv("gemini_api") # Ensure your API key is set
|
| 9 |
client = genai.Client(api_key=GOOGLE_API_KEY)
|
| 10 |
+
global chat
|
| 11 |
+
chat=None
|
| 12 |
def transcribe_audio(audio_path):
|
| 13 |
"""
|
| 14 |
Transcribe the audio file using the Gemini API.
|
|
|
|
| 43 |
"""
|
| 44 |
if history is None or not isinstance(history, list): # Ensure history is initialized
|
| 45 |
history = []
|
| 46 |
+
|
| 47 |
# Initialize or continue conversation
|
| 48 |
if chat is None:
|
| 49 |
chat = client.chats.create(model="gemini-2.0-flash") # Initialize chat once
|