Spaces:
Runtime error
Runtime error
Add app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import yaml
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
from agno.agent import Agent
|
| 6 |
+
from agno.models.nebius import Nebius
|
| 7 |
+
from agno.tools.github import GithubTools
|
| 8 |
+
from agno.tools.exa import ExaTools
|
| 9 |
+
from agno.tools.thinking import ThinkingTools
|
| 10 |
+
from agno.tools.reasoning import ReasoningTools
|
| 11 |
+
|
| 12 |
+
# Load environment variables from .env if present
|
| 13 |
+
load_dotenv()
|
| 14 |
+
|
| 15 |
+
# Load prompts from YAML file
|
| 16 |
+
with open("hiring_prompts.yaml", "r", encoding="utf-8") as f:
|
| 17 |
+
prompts = yaml.safe_load(f)
|
| 18 |
+
|
| 19 |
+
# Extract prompt sections
|
| 20 |
+
description_multi = prompts.get("description_for_multi_candidates", "")
|
| 21 |
+
instructions_multi = prompts.get("instructions_for_multi_candidates", "")
|
| 22 |
+
description_single = prompts.get("description_for_single_candidate", "")
|
| 23 |
+
instructions_single = prompts.get("instructions_for_single_candidate", "")
|
| 24 |
+
|
| 25 |
+
def analyze_multi(github_usernames, job_role, nebius_api_key, model_id, github_api_key, exa_api_key):
|
| 26 |
+
"""
|
| 27 |
+
Analyze multiple GitHub users for a given job role.
|
| 28 |
+
github_usernames: string with newline separated usernames.
|
| 29 |
+
Returns a markdown report.
|
| 30 |
+
"""
|
| 31 |
+
if not github_usernames or not job_role:
|
| 32 |
+
return "Please provide GitHub usernames and job role."
|
| 33 |
+
usernames = [u.strip() for u in github_usernames.split("\n") if u.strip()]
|
| 34 |
+
if not usernames:
|
| 35 |
+
return "No valid GitHub usernames found."
|
| 36 |
+
query = f"Evaluate GitHub candidates for role '{job_role}': {', '.join(usernames)}"
|
| 37 |
+
agent = Agent(
|
| 38 |
+
description=description_multi,
|
| 39 |
+
instructions=instructions_multi,
|
| 40 |
+
model=Nebius(id=model_id, api_key=nebius_api_key),
|
| 41 |
+
name="CandilyzerMulti",
|
| 42 |
+
tools=[
|
| 43 |
+
ThinkingTools(think=True, instructions="Strict GitHub candidate evaluation"),
|
| 44 |
+
GithubTools(access_token=github_api_key),
|
| 45 |
+
ExaTools(api_key=exa_api_key, include_domains=["github.com"], type="keyword"),
|
| 46 |
+
ReasoningTools(add_instructions=True),
|
| 47 |
+
],
|
| 48 |
+
markdown=True,
|
| 49 |
+
show_tool_calls=True,
|
| 50 |
+
)
|
| 51 |
+
stream = agent.run(query, stream=True)
|
| 52 |
+
output = ""
|
| 53 |
+
for chunk in stream:
|
| 54 |
+
if hasattr(chunk, "content") and isinstance(chunk.content, str):
|
| 55 |
+
output += chunk.content
|
| 56 |
+
return output
|
| 57 |
+
|
| 58 |
+
def analyze_single(github_username, linkedin_url, job_role, nebius_api_key, model_id, github_api_key, exa_api_key):
|
| 59 |
+
"""
|
| 60 |
+
Analyze a single GitHub (and optional LinkedIn) candidate for a given job role.
|
| 61 |
+
"""
|
| 62 |
+
if not github_username or not job_role:
|
| 63 |
+
return "Please provide GitHub username and job role."
|
| 64 |
+
query = f"Analyze candidate for {job_role}. GitHub: {github_username}"
|
| 65 |
+
if linkedin_url:
|
| 66 |
+
query += f", LinkedIn: {linkedin_url}"
|
| 67 |
+
agent = Agent(
|
| 68 |
+
description=description_single,
|
| 69 |
+
instructions=instructions_single,
|
| 70 |
+
model=Nebius(id=model_id, api_key=nebius_api_key),
|
| 71 |
+
name="CandilyzerSingle",
|
| 72 |
+
tools=[
|
| 73 |
+
ThinkingTools(add_instructions=True),
|
| 74 |
+
GithubTools(access_token=github_api_key),
|
| 75 |
+
ExaTools(api_key=exa_api_key, include_domains=["linkedin.com", "github.com"], type="keyword"),
|
| 76 |
+
ReasoningTools(add_instructions=True),
|
| 77 |
+
],
|
| 78 |
+
markdown=True,
|
| 79 |
+
show_tool_calls=True,
|
| 80 |
+
add_datetime_to_instructions=True,
|
| 81 |
+
)
|
| 82 |
+
stream = agent.run(query, stream=True)
|
| 83 |
+
output = ""
|
| 84 |
+
for chunk in stream:
|
| 85 |
+
if hasattr(chunk, "content") and isinstance(chunk.content, str):
|
| 86 |
+
output += chunk.content
|
| 87 |
+
return output
|
| 88 |
+
|
| 89 |
+
with gr.Blocks() as demo:
|
| 90 |
+
gr.Markdown("# Candilyzer\nAI Candidate Analyzer using Agno and Nebius AI")
|
| 91 |
+
with gr.Tab("Multi-Candidate Analyzer"):
|
| 92 |
+
github_usernames = gr.Textbox(label="GitHub Usernames (one per line)", lines=4, placeholder="username1\nusername2\n...")
|
| 93 |
+
job_role = gr.Textbox(label="Job Role", placeholder="Backend Engineer")
|
| 94 |
+
nebius_api_key = gr.Textbox(label="Nebius API Key", type="password")
|
| 95 |
+
model_id = gr.Textbox(label="Model ID", placeholder="meta-llama/Llama-3-70B-Instruct")
|
| 96 |
+
github_api_key = gr.Textbox(label="GitHub API Key", type="password")
|
| 97 |
+
exa_api_key = gr.Textbox(label="Exa API Key", type="password")
|
| 98 |
+
multi_button = gr.Button("Analyze Candidates")
|
| 99 |
+
multi_output = gr.Markdown()
|
| 100 |
+
multi_button.click(analyze_multi, inputs=[github_usernames, job_role, nebius_api_key, model_id, github_api_key, exa_api_key], outputs=multi_output)
|
| 101 |
+
|
| 102 |
+
with gr.Tab("Single Candidate Analyzer"):
|
| 103 |
+
github_username = gr.Textbox(label="GitHub Username", placeholder="username")
|
| 104 |
+
linkedin_url = gr.Textbox(label="LinkedIn Profile (optional)", placeholder="https://linkedin.com/in/...")
|
| 105 |
+
job_role2 = gr.Textbox(label="Job Role", placeholder="ML Engineer")
|
| 106 |
+
nebius_api_key2 = gr.Textbox(label="Nebius API Key", type="password")
|
| 107 |
+
model_id2 = gr.Textbox(label="Model ID", placeholder="meta-llama/Llama-3-70B-Instruct")
|
| 108 |
+
github_api_key2 = gr.Textbox(label="GitHub API Key", type="password")
|
| 109 |
+
exa_api_key2 = gr.Textbox(label="Exa API Key", type="password")
|
| 110 |
+
single_button = gr.Button("Analyze Candidate")
|
| 111 |
+
single_output = gr.Markdown()
|
| 112 |
+
single_button.click(analyze_single, inputs=[github_username, linkedin_url, job_role2, nebius_api_key2, model_id2, github_api_key2, exa_api_key2], outputs=single_output)
|
| 113 |
+
|
| 114 |
+
demo.launch()
|