Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,8 +11,7 @@ from dotenv import load_dotenv
|
|
| 11 |
from datetime import datetime
|
| 12 |
import requests
|
| 13 |
from requests.exceptions import RequestException
|
| 14 |
-
from typing import Optional,
|
| 15 |
-
Dict, Any
|
| 16 |
from download import download_video_audio, delete_download
|
| 17 |
from st_audiorec import st_audiorec # Import the audio recorder component
|
| 18 |
|
|
@@ -26,6 +25,10 @@ load_dotenv()
|
|
| 26 |
# Initialize session states
|
| 27 |
if 'api_key' not in st.session_state:
|
| 28 |
st.session_state.api_key = os.environ.get("GROQ_API_KEY", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
if 'transcript' not in st.session_state:
|
| 31 |
st.session_state.transcript = ""
|
|
@@ -62,6 +65,7 @@ def initialize_groq_client(api_key: str) -> Optional[Groq]:
|
|
| 62 |
try:
|
| 63 |
client = Groq(api_key=api_key)
|
| 64 |
# Perform a simple test call to validate the API key
|
|
|
|
| 65 |
client.models.list()
|
| 66 |
return client
|
| 67 |
except Exception as e:
|
|
|
|
| 11 |
from datetime import datetime
|
| 12 |
import requests
|
| 13 |
from requests.exceptions import RequestException
|
| 14 |
+
from typing import Optional, Dict, Any
|
|
|
|
| 15 |
from download import download_video_audio, delete_download
|
| 16 |
from st_audiorec import st_audiorec # Import the audio recorder component
|
| 17 |
|
|
|
|
| 25 |
# Initialize session states
|
| 26 |
if 'api_key' not in st.session_state:
|
| 27 |
st.session_state.api_key = os.environ.get("GROQ_API_KEY", "")
|
| 28 |
+
# For Streamlit Cloud or Hugging Face
|
| 29 |
+
if not st.session_state.api_key and st.secrets and "GROQ_API_KEY" in st.secrets:
|
| 30 |
+
st.session_state.api_key = st.secrets["GROQ_API_KEY"]
|
| 31 |
+
|
| 32 |
|
| 33 |
if 'transcript' not in st.session_state:
|
| 34 |
st.session_state.transcript = ""
|
|
|
|
| 65 |
try:
|
| 66 |
client = Groq(api_key=api_key)
|
| 67 |
# Perform a simple test call to validate the API key
|
| 68 |
+
|
| 69 |
client.models.list()
|
| 70 |
return client
|
| 71 |
except Exception as e:
|