Spaces:
Sleeping
Sleeping
Commit
·
95fb3fe
1
Parent(s):
c6d58fd
Add Dockerfile and update API key handling for Hugging Face deployment
Browse files- rag/rag_query.py +6 -2
rag/rag_query.py
CHANGED
|
@@ -1,15 +1,19 @@
|
|
| 1 |
"""Module for querying the Groq API with dataset context."""
|
| 2 |
|
| 3 |
from groq import Groq, APIStatusError
|
| 4 |
-
from config import GROQ_API_KEY
|
| 5 |
from rag.memory import get_dataset
|
| 6 |
import pandas as pd
|
| 7 |
import logging
|
|
|
|
| 8 |
|
| 9 |
# Configure logging for this module
|
| 10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 11 |
|
| 12 |
-
# Initialize Groq client with API key from
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
client = Groq(api_key=GROQ_API_KEY)
|
| 14 |
|
| 15 |
def query_dataset_with_groq(dataset_name, user_query):
|
|
|
|
| 1 |
"""Module for querying the Groq API with dataset context."""
|
| 2 |
|
| 3 |
from groq import Groq, APIStatusError
|
|
|
|
| 4 |
from rag.memory import get_dataset
|
| 5 |
import pandas as pd
|
| 6 |
import logging
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
# Configure logging for this module
|
| 10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 11 |
|
| 12 |
+
# Initialize Groq client with API key from environment variable
|
| 13 |
+
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 14 |
+
if not GROQ_API_KEY:
|
| 15 |
+
logging.error("GROQ_API_KEY environment variable not set. Please set it in Hugging Face Space Secrets.")
|
| 16 |
+
raise ValueError("GROQ_API_KEY environment variable not set.")
|
| 17 |
client = Groq(api_key=GROQ_API_KEY)
|
| 18 |
|
| 19 |
def query_dataset_with_groq(dataset_name, user_query):
|