UnivAI-agents / Job Finder /formatter.py
UnivAI001
initial commit - AI automation agents
6798e8f
Raw
History Blame Contribute Delete
1.26 kB
import os
from groq import Groq
from dotenv import load_dotenv
from pathlib import Path
env_file = Path(__file__).parent / ".env"
if not env_file.exists():
env_file = Path(__file__).parent.parent / ".env"
load_dotenv(env_file)
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
def format_jobs(jobs, job_title, experience_level):
if not jobs:
return "No jobs found. Try different search terms."
raw = ""
for i, job in enumerate(jobs):
raw += f"""
Job {i+1}:
Title: {job['title']}
Company: {job['company']}
Location: {job['location']}
URL: {job['url']}
Description: {job['description']}
---
"""
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[
{
"role": "system",
"content": "You are a job search assistant. Format job listings clearly and helpfully."
},
{
"role": "user",
"content": f"""
Here are raw job listings for a {experience_level} {job_title}.
Format each one cleanly with:
- Job title and company
- Location
- Key requirements from description
- Direct apply link
Raw data:
{raw}
"""
}
]
)
return response.choices[0].message.content