Inhance / evaluator_agent.py
yashgori20's picture
done
492af8a
import streamlit as st
import json
from groq import Groq
from config import Config
def evaluate_linkedin_profile(profile_data):
try:
client = Groq(api_key=Config.GROQ_API_KEY)
except Exception as e:
st.error(f"❌ Groq API Configuration Error: {str(e)}")
st.info("Please check your Groq API key configuration.")
return "Error: Groq API configuration failed"
messages = [
{
"role": "system",
"content": (
"You are an AI assistant specialized in evaluating LinkedIn profiles. "
"Assess the provided profile data in detail according to the specified criteria. "
"Provide detailed observations for:\n"
"2. Headline and Summary\n"
"3. Experience Section\n"
"5. Custom URL and Creator Mode\n"
"6. Engagement and Content Sharing\n"
"7. Certifications, Licenses, and Education\n"
"8. Featured Section and Multimedia\n"
"11. Role-Specific Evaluation"
)
},
{
"role": "user",
"content": f"Profile Data: {json.dumps(profile_data)}"
}
]
try:
completion = client.chat.completions.create(
model="openai/gpt-oss-120b",
messages=messages,
max_tokens=30000,
temperature=0.5
)
# Clean markdown formatting from GPT-OSS response
content = completion.choices[0].message.content
content = content.replace('**', '').replace('*', '') # Remove markdown formatting
return content
except Exception as e:
st.error(f"❌ Groq API Error: {str(e)}")
if "organization_restricted" in str(e):
st.warning("🔑 Your Groq API key has been restricted. Please:")
st.info("1. Check your Groq account at https://console.groq.com/\n2. Generate a new API key\n3. Update your .env file")
return f"Error: {str(e)}"