Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,22 +13,10 @@ import whisper
|
|
| 13 |
import requests
|
| 14 |
from dotenv import load_dotenv
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# Step 3: Custom function to interact with the Groq API
|
| 21 |
-
def get_groq_embeddings(text_chunks):
|
| 22 |
-
url = "https://api.groq.com/your-endpoint" # Replace with the correct Groq API endpoint
|
| 23 |
-
headers = {"Authorization": f"Bearer {groq_api_key}"}
|
| 24 |
-
payload = {"text_chunks": text_chunks}
|
| 25 |
-
response = requests.post(url, json=payload, headers=headers)
|
| 26 |
-
|
| 27 |
-
if response.status_code == 200:
|
| 28 |
-
return response.json()["embeddings"]
|
| 29 |
-
else:
|
| 30 |
-
st.error(f"Error: {response.status_code} - {response.text}")
|
| 31 |
-
return None
|
| 32 |
|
| 33 |
# Step 4: Function to read files and extract text
|
| 34 |
def extract_text(file):
|
|
|
|
| 13 |
import requests
|
| 14 |
from dotenv import load_dotenv
|
| 15 |
|
| 16 |
+
# Load the Groq API key from the environment variable
|
| 17 |
+
api_key = os.getenv("GROQ_API_KEY")
|
| 18 |
+
if not api_key:
|
| 19 |
+
raise ValueError("No API key found. Please set the GROQ_API_KEY environment variable.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Step 4: Function to read files and extract text
|
| 22 |
def extract_text(file):
|