Spaces:
Sleeping
Sleeping
Simplify Groq initialization - remove try-except to fix indentation
Browse files
main.py
CHANGED
|
@@ -37,17 +37,12 @@ app.add_middleware(
|
|
| 37 |
|
| 38 |
# Initialize Groq client
|
| 39 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
except Exception as e:
|
| 45 |
-
logger.error(f"Error initializing Groq: {str(e)}")
|
| 46 |
-
groq_client = None
|
| 47 |
else:
|
| 48 |
-
groq_client = None
|
| 49 |
logger.warning("GROQ_API_KEY not found - running in demo mode")
|
| 50 |
-
|
| 51 |
# Request/Response Models
|
| 52 |
class QueryRequest(BaseModel):
|
| 53 |
question: str
|
|
|
|
| 37 |
|
| 38 |
# Initialize Groq client
|
| 39 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 40 |
+
# Initialize Groq client
|
| 41 |
+
groq_client = Groq(api_key=GROQ_API_KEY) if GROQ_API_KEY else None
|
| 42 |
+
if groq_client:
|
| 43 |
+
logger.info("Groq client initialized successfully")
|
|
|
|
|
|
|
|
|
|
| 44 |
else:
|
|
|
|
| 45 |
logger.warning("GROQ_API_KEY not found - running in demo mode")
|
|
|
|
| 46 |
# Request/Response Models
|
| 47 |
class QueryRequest(BaseModel):
|
| 48 |
question: str
|