Spaces:
Configuration error
Configuration error
Simplified API key management and moved model instantiation out of configuration file
Browse files- .github/workflows/python_ci.yml +1 -1
- configuration.py +15 -17
- functions/job_call.py +10 -3
- functions/writer_agent.py +10 -4
.github/workflows/python_ci.yml
CHANGED
|
@@ -24,7 +24,7 @@ jobs:
|
|
| 24 |
pip install -r requirements.txt
|
| 25 |
- name: Test with unittest
|
| 26 |
env:
|
| 27 |
-
ANTHROPIC_API_KEY: ${{ secrets.
|
| 28 |
run: |
|
| 29 |
python -m unittest tests/test_gradio.py
|
| 30 |
python -m unittest tests/test_linkedin_resume.py
|
|
|
|
| 24 |
pip install -r requirements.txt
|
| 25 |
- name: Test with unittest
|
| 26 |
env:
|
| 27 |
+
ANTHROPIC_API_KEY: ${{ secrets.API_KEY }}
|
| 28 |
run: |
|
| 29 |
python -m unittest tests/test_gradio.py
|
| 30 |
python -m unittest tests/test_linkedin_resume.py
|
configuration.py
CHANGED
|
@@ -1,21 +1,19 @@
|
|
| 1 |
"""Global configuration for the Resumate application."""
|
| 2 |
|
| 3 |
-
import os
|
| 4 |
-
from openai import OpenAI
|
| 5 |
-
from smolagents import OpenAIServerModel
|
| 6 |
-
|
| 7 |
DEFAULT_GITHUB_PROFILE = "https://github.com/gperdrizet"
|
| 8 |
|
|
|
|
|
|
|
| 9 |
# Will be used for single shot summarization with no-frills prompting
|
| 10 |
# (e.g. job call extraction). It needs to output JSON formatted text,
|
| 11 |
# but this task does not require any complex reasoning or planning.
|
| 12 |
-
SUMMARIZER_CLIENT = OpenAI(
|
| 13 |
-
base_url="https://api.anthropic.com/v1/",
|
| 14 |
-
api_key=os.environ.get("ANTHROPIC_API_KEY", "dummy-key-for-testing")
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
SUMMARIZER_MODEL = "claude-3-5-haiku-20241022"
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Will be used for resume resume writing agent via HuggingFace smolagents
|
| 20 |
# Including selection of relevant projects from GitHub profile
|
| 21 |
#
|
|
@@ -25,14 +23,14 @@ SUMMARIZER_MODEL = "claude-3-5-haiku-20241022"
|
|
| 25 |
# - Qwen2.5-Coder-14B-Instruct works OK, but is not great at markdown formatting
|
| 26 |
# and tends to get some details wrong.
|
| 27 |
# - Claude-3-5-Haiku is the best model for this task so far.
|
| 28 |
-
|
| 29 |
-
AGENT_MODEL = OpenAIServerModel(
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
)
|
| 34 |
-
|
| 35 |
-
|
| 36 |
You are an AI agent responsible for writing a resume based on the provided context. Your task is to generate a well-structured and professional resume that highlights the user's skills, experiences, and achievements.
|
| 37 |
You will receive two pieces of JSON structured context: a job call and a LinkedIn profile.
|
| 38 |
|
|
|
|
| 1 |
"""Global configuration for the Resumate application."""
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
DEFAULT_GITHUB_PROFILE = "https://github.com/gperdrizet"
|
| 4 |
|
| 5 |
+
INFERENCE_URL = "https://api.anthropic.com/v1/"
|
| 6 |
+
|
| 7 |
# Will be used for single shot summarization with no-frills prompting
|
| 8 |
# (e.g. job call extraction). It needs to output JSON formatted text,
|
| 9 |
# but this task does not require any complex reasoning or planning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
SUMMARIZER_MODEL = "claude-3-5-haiku-20241022"
|
| 11 |
|
| 12 |
+
# SUMMARIZER_CLIENT = OpenAI(
|
| 13 |
+
# base_url="https://api.anthropic.com/v1/",
|
| 14 |
+
# api_key=os.environ.get("ANTHROPIC_API_KEY", "dummy-key-for-testing")
|
| 15 |
+
# )
|
| 16 |
+
|
| 17 |
# Will be used for resume resume writing agent via HuggingFace smolagents
|
| 18 |
# Including selection of relevant projects from GitHub profile
|
| 19 |
#
|
|
|
|
| 23 |
# - Qwen2.5-Coder-14B-Instruct works OK, but is not great at markdown formatting
|
| 24 |
# and tends to get some details wrong.
|
| 25 |
# - Claude-3-5-Haiku is the best model for this task so far.
|
| 26 |
+
AGENT_MODEL = "claude-3-5-haiku-20241022"
|
| 27 |
+
# AGENT_MODEL = OpenAIServerModel(
|
| 28 |
+
# model_id="claude-3-5-haiku-20241022", # Same as HF model string
|
| 29 |
+
# api_base="https://api.anthropic.com/v1/",
|
| 30 |
+
# api_key=os.environ.get("ANTHROPIC_API_KEY", "dummy-key-for-testing"),
|
| 31 |
+
# )
|
| 32 |
+
|
| 33 |
+
AGENT_INSTRUCTIONS = """
|
| 34 |
You are an AI agent responsible for writing a resume based on the provided context. Your task is to generate a well-structured and professional resume that highlights the user's skills, experiences, and achievements.
|
| 35 |
You will receive two pieces of JSON structured context: a job call and a LinkedIn profile.
|
| 36 |
|
functions/job_call.py
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
'''Functions for summarizing and formatting job calls.'''
|
| 2 |
|
|
|
|
| 3 |
import json
|
| 4 |
import logging
|
| 5 |
from pathlib import Path
|
| 6 |
from datetime import datetime
|
|
|
|
| 7 |
from configuration import (
|
| 8 |
-
|
| 9 |
SUMMARIZER_MODEL,
|
| 10 |
-
|
| 11 |
)
|
| 12 |
|
| 13 |
# pylint: disable=broad-exception-caught
|
|
@@ -61,6 +63,11 @@ def summarize_job_call(job_call: str) -> str:
|
|
| 61 |
|
| 62 |
logger.info("Summarizing job call (%d characters)", len(job_call))
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
messages = [
|
| 65 |
{
|
| 66 |
'role': 'system',
|
|
@@ -74,7 +81,7 @@ def summarize_job_call(job_call: str) -> str:
|
|
| 74 |
}
|
| 75 |
|
| 76 |
try:
|
| 77 |
-
response =
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
response = None
|
|
|
|
| 1 |
'''Functions for summarizing and formatting job calls.'''
|
| 2 |
|
| 3 |
+
import os
|
| 4 |
import json
|
| 5 |
import logging
|
| 6 |
from pathlib import Path
|
| 7 |
from datetime import datetime
|
| 8 |
+
from openai import OpenAI
|
| 9 |
from configuration import (
|
| 10 |
+
INFERENCE_URL,
|
| 11 |
SUMMARIZER_MODEL,
|
| 12 |
+
JOB_CALL_EXTRACTION_PROMPT
|
| 13 |
)
|
| 14 |
|
| 15 |
# pylint: disable=broad-exception-caught
|
|
|
|
| 63 |
|
| 64 |
logger.info("Summarizing job call (%d characters)", len(job_call))
|
| 65 |
|
| 66 |
+
client = OpenAI(
|
| 67 |
+
base_url=INFERENCE_URL,
|
| 68 |
+
api_key=os.environ.get("API_KEY", "dummy-key-for-testing")
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
messages = [
|
| 72 |
{
|
| 73 |
'role': 'system',
|
|
|
|
| 81 |
}
|
| 82 |
|
| 83 |
try:
|
| 84 |
+
response = client.chat.completions.create(**completion_args)
|
| 85 |
|
| 86 |
except Exception as e:
|
| 87 |
response = None
|
functions/writer_agent.py
CHANGED
|
@@ -3,8 +3,8 @@
|
|
| 3 |
import json
|
| 4 |
import logging
|
| 5 |
import os
|
| 6 |
-
from smolagents import CodeAgent
|
| 7 |
-
from configuration import AGENT_MODEL,
|
| 8 |
|
| 9 |
# pylint: disable=broad-exception-caught
|
| 10 |
|
|
@@ -27,8 +27,14 @@ def write_resume(content: str, user_instructions: str = None, job_summary: str =
|
|
| 27 |
|
| 28 |
if content['status'] == 'success':
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
agent = CodeAgent(
|
| 31 |
-
model=
|
| 32 |
tools=[],
|
| 33 |
additional_authorized_imports=['json', 'pandas'],
|
| 34 |
name="writer_agent",
|
|
@@ -38,7 +44,7 @@ def write_resume(content: str, user_instructions: str = None, job_summary: str =
|
|
| 38 |
)
|
| 39 |
|
| 40 |
# Prepare instructions - combine default with user instructions and job summary
|
| 41 |
-
instructions =
|
| 42 |
|
| 43 |
if job_summary is not None and job_summary.strip():
|
| 44 |
instructions += f"\n\nJob Requirements and Details:\n{job_summary.strip()}"
|
|
|
|
| 3 |
import json
|
| 4 |
import logging
|
| 5 |
import os
|
| 6 |
+
from smolagents import OpenAIServerModel, CodeAgent
|
| 7 |
+
from configuration import INFERENCE_URL, AGENT_MODEL, AGENT_INSTRUCTIONS
|
| 8 |
|
| 9 |
# pylint: disable=broad-exception-caught
|
| 10 |
|
|
|
|
| 27 |
|
| 28 |
if content['status'] == 'success':
|
| 29 |
|
| 30 |
+
model = OpenAIServerModel(
|
| 31 |
+
model_id=AGENT_MODEL,
|
| 32 |
+
api_base=INFERENCE_URL,
|
| 33 |
+
api_key=os.environ.get("API_KEY"),
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
agent = CodeAgent(
|
| 37 |
+
model=model,
|
| 38 |
tools=[],
|
| 39 |
additional_authorized_imports=['json', 'pandas'],
|
| 40 |
name="writer_agent",
|
|
|
|
| 44 |
)
|
| 45 |
|
| 46 |
# Prepare instructions - combine default with user instructions and job summary
|
| 47 |
+
instructions = AGENT_INSTRUCTIONS
|
| 48 |
|
| 49 |
if job_summary is not None and job_summary.strip():
|
| 50 |
instructions += f"\n\nJob Requirements and Details:\n{job_summary.strip()}"
|