Parimal Kalpande commited on
Commit ·
9b2985f
1
Parent(s): 2267dcb
Fix Groq client initialization and remove unsupported Gradio launch parameters
Browse files- app.py +1 -3
- modules/llm_handler.py +20 -14
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -350,9 +350,7 @@ if __name__ == "__main__":
|
|
| 350 |
server_name="0.0.0.0",
|
| 351 |
server_port=7860,
|
| 352 |
share=False,
|
| 353 |
-
show_error=False
|
| 354 |
-
enable_queue=True,
|
| 355 |
-
max_threads=10
|
| 356 |
)
|
| 357 |
else:
|
| 358 |
# Running locally
|
|
|
|
| 350 |
server_name="0.0.0.0",
|
| 351 |
server_port=7860,
|
| 352 |
share=False,
|
| 353 |
+
show_error=False # Disable detailed errors for production
|
|
|
|
|
|
|
| 354 |
)
|
| 355 |
else:
|
| 356 |
# Running locally
|
modules/llm_handler.py
CHANGED
|
@@ -2,26 +2,32 @@
|
|
| 2 |
import os
|
| 3 |
import config
|
| 4 |
import regex as re
|
| 5 |
-
from groq import Groq
|
| 6 |
-
from modules.web_search import search_for_example_answers
|
| 7 |
-
from modules.pm_frameworks import get_framework_suggestion, get_relevant_metrics
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
if not api_key:
|
| 13 |
-
raise ValueError("GROQ_API_KEY is required. Please set it in .env file or environment variables.")
|
| 14 |
-
# Simple initialization without extra parameters
|
| 15 |
-
return Groq(api_key=api_key)
|
| 16 |
|
| 17 |
try:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
except Exception as e:
|
| 22 |
print(f"❌ Failed to initialize Groq client: {e}")
|
| 23 |
client = None
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def generate_coaching_question(coaching_type, document_text, question_number):
|
| 27 |
"""Generate a personalized, interview-style product management coaching question based on resume."""
|
|
|
|
| 2 |
import os
|
| 3 |
import config
|
| 4 |
import regex as re
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Import Groq with fallback
|
| 7 |
+
client = None
|
| 8 |
+
MODEL = "llama3-8b-8192"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
try:
|
| 11 |
+
from groq import Groq
|
| 12 |
+
|
| 13 |
+
# Get API key
|
| 14 |
+
api_key = config.GROQ_API_KEY or os.environ.get("GROQ_API_KEY")
|
| 15 |
+
if api_key:
|
| 16 |
+
# Try simple initialization
|
| 17 |
+
client = Groq(api_key=api_key)
|
| 18 |
+
MODEL = config.GROQ_MODEL
|
| 19 |
+
print(f"✅ Groq API connected successfully with model: {MODEL}")
|
| 20 |
+
else:
|
| 21 |
+
print("❌ GROQ_API_KEY not found")
|
| 22 |
+
|
| 23 |
+
except ImportError as e:
|
| 24 |
+
print(f"❌ Failed to import Groq: {e}")
|
| 25 |
except Exception as e:
|
| 26 |
print(f"❌ Failed to initialize Groq client: {e}")
|
| 27 |
client = None
|
| 28 |
+
|
| 29 |
+
from modules.web_search import search_for_example_answers
|
| 30 |
+
from modules.pm_frameworks import get_framework_suggestion, get_relevant_metrics
|
| 31 |
|
| 32 |
def generate_coaching_question(coaching_type, document_text, question_number):
|
| 33 |
"""Generate a personalized, interview-style product management coaching question based on resume."""
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
gradio==4.36.1
|
| 2 |
-
groq==0.
|
| 3 |
openai-whisper==20231117
|
| 4 |
pydub==0.25.1
|
| 5 |
soundfile==0.12.1
|
|
|
|
| 1 |
gradio==4.36.1
|
| 2 |
+
groq==0.8.0
|
| 3 |
openai-whisper==20231117
|
| 4 |
pydub==0.25.1
|
| 5 |
soundfile==0.12.1
|