Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import PyPDF2
|
|
| 5 |
import docx
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
-
# 1. CORE ENGINE (
|
| 9 |
# ==========================================
|
| 10 |
def get_client():
|
| 11 |
api_key = os.environ.get("GROQ_API_KEY")
|
|
@@ -46,20 +46,20 @@ def stream_llm(system_role, user_text, audio_path=None, file_path=None):
|
|
| 46 |
if file_path:
|
| 47 |
content = extract_text(file_path)
|
| 48 |
if len(content) > 30000:
|
| 49 |
-
yield "### ⚠️ Limit Exceeded\nYour CV is too large.
|
| 50 |
return
|
| 51 |
file_context = f"\n[CV Content]:\n{content}"
|
| 52 |
|
| 53 |
combined_input = f"User Target: {user_text}\nVoice: {voice_content}\n{file_context}".strip()
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
models = ["llama-3.3-70b-versatile", "
|
| 57 |
|
| 58 |
success = False
|
| 59 |
for model_name in models:
|
| 60 |
try:
|
| 61 |
client = get_client()
|
| 62 |
-
detail_cmd = "\n\nSTRICT: Respond ONLY in user's language.
|
| 63 |
|
| 64 |
response = client.chat.completions.create(
|
| 65 |
model=model_name,
|
|
@@ -75,23 +75,20 @@ def stream_llm(system_role, user_text, audio_path=None, file_path=None):
|
|
| 75 |
partial_text += chunk.choices[0].delta.content
|
| 76 |
yield partial_text
|
| 77 |
success = True
|
| 78 |
-
break
|
| 79 |
except Exception as e:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
else:
|
| 83 |
-
yield f"### ⚠️ Error\n{str(e)}"
|
| 84 |
-
return
|
| 85 |
|
| 86 |
if not success:
|
| 87 |
-
yield "### ⚠️
|
| 88 |
|
| 89 |
# ==========================================
|
| 90 |
-
# 2. PROMPTS & UI (
|
| 91 |
# ==========================================
|
| 92 |
-
NEXUS_PROMPT = "Analyze Dream Company:
|
| 93 |
-
ZEN_PROMPT = "Motivational Strategist.
|
| 94 |
-
ORBIT_PROMPT = "Career Architect. Dream company + SALARY. 6-month roadmap
|
| 95 |
PATH_PROMPT = "Industry Scout. Identify 5-10 industries/companies for this CV. Provide SALARY, direct links, and hiring strategy."
|
| 96 |
|
| 97 |
custom_css = """
|
|
|
|
| 5 |
import docx
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
+
# 1. CORE ENGINE (FIXED MODELS LIST)
|
| 9 |
# ==========================================
|
| 10 |
def get_client():
|
| 11 |
api_key = os.environ.get("GROQ_API_KEY")
|
|
|
|
| 46 |
if file_path:
|
| 47 |
content = extract_text(file_path)
|
| 48 |
if len(content) > 30000:
|
| 49 |
+
yield "### ⚠️ Limit Exceeded\nYour CV is too large."
|
| 50 |
return
|
| 51 |
file_context = f"\n[CV Content]:\n{content}"
|
| 52 |
|
| 53 |
combined_input = f"User Target: {user_text}\nVoice: {voice_content}\n{file_context}".strip()
|
| 54 |
|
| 55 |
+
# UPDATED MODELS: Removed decommissioned 'llama3-70b-8192'
|
| 56 |
+
models = ["llama-3.3-70b-versatile", "llama-3.1-70b-versatile", "mixtral-8x7b-32768"]
|
| 57 |
|
| 58 |
success = False
|
| 59 |
for model_name in models:
|
| 60 |
try:
|
| 61 |
client = get_client()
|
| 62 |
+
detail_cmd = "\n\nSTRICT: Respond ONLY in user's language. Exhaustive detail, salary ranges, and 10 clickable links."
|
| 63 |
|
| 64 |
response = client.chat.completions.create(
|
| 65 |
model=model_name,
|
|
|
|
| 75 |
partial_text += chunk.choices[0].delta.content
|
| 76 |
yield partial_text
|
| 77 |
success = True
|
| 78 |
+
break
|
| 79 |
except Exception as e:
|
| 80 |
+
# Try next model if rate limit or model error
|
| 81 |
+
continue
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
if not success:
|
| 84 |
+
yield "### ⚠️ Service Temporarily Busy\nAll high-end models are at capacity. Please refresh in 1 minute."
|
| 85 |
|
| 86 |
# ==========================================
|
| 87 |
+
# 2. PROMPTS & UI (AS PER YOUR REQUIREMENTS)
|
| 88 |
# ==========================================
|
| 89 |
+
NEXUS_PROMPT = "Analyze Dream Company: Roles/Benefits. Extract CV. Strengths, Weaknesses, Skill Matrix."
|
| 90 |
+
ZEN_PROMPT = "Motivational Strategist. Use examples: Edison, Sanders, J.K. Rowling, Steve Jobs, Jack Ma. Massive length."
|
| 91 |
+
ORBIT_PROMPT = "Career Architect. Dream company + SALARY. 6-month roadmap with links."
|
| 92 |
PATH_PROMPT = "Industry Scout. Identify 5-10 industries/companies for this CV. Provide SALARY, direct links, and hiring strategy."
|
| 93 |
|
| 94 |
custom_css = """
|