Spaces:
Runtime error
Runtime error
| from groq import Groq | |
| import os | |
| class SkillExtractor: | |
| def __init__(self): | |
| self.client = Groq(api_key=os.environ.get("GROQ_API_KEY")) | |
| def extract_skills(self, text): | |
| """Extract skills using Llama model with improved prompting.""" | |
| try: | |
| prompt = """ | |
| Extract a list of technical and soft skills from the following text. | |
| Format the output as a comma-separated list. | |
| Include only clear, specific skills (e.g., 'Python', 'Project Management', 'AWS'). | |
| Text: {text} | |
| Skills: | |
| """ | |
| chat_completion = self.client.chat.completions.create( | |
| messages=[{"role": "user", "content": prompt.format(text=text)}], | |
| model="llama3-70b-8192", | |
| temperature=0.3, # Lower temperature for more focused results | |
| max_tokens=500 | |
| ) | |
| skills = [ | |
| skill.strip() | |
| for skill in chat_completion.choices[0].message.content.split(',') | |
| if skill.strip() | |
| ] | |
| return list(set(skills)) # Remove duplicates | |
| except Exception as e: | |
| return [f"Error extracting skills: {str(e)}"] |