Skip to content

Commit

Permalink
create new custom adeptid tool
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgee committed Jul 16, 2024
1 parent b57ce85 commit 48ecc75
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
postgres-volume/
redis-volume/
backend/ui
tests/notebooks

# Operating System generated files
.DS_Store
Expand Down
67 changes: 62 additions & 5 deletions backend/custom_tools/adeptid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from typing import List
import os

ADEPT_ID_API_KEY =

# Define the input schema for the tool
class WorkHistory(BaseModel):
title: str
Expand All @@ -26,21 +28,75 @@ class Candidate(BaseModel):
education: List[Education]
skills: List[str]

class AdeptIDJobRecommendationInput(BaseModel):
class AdeptIDSkillSearchInput(BaseModel):
skills: List[str]
result_count: int = 1
offset: int = 1

class AdeptIDDestionationOccupationRecommendationInput(BaseModel):
candidates: List[Candidate]
limit: int = 10
offset: int = 1
skill_count: int = 5

class AdeptIDJobRecommendationInput(BaseModel):
skill_count: int = 0
destination_jobs: List[str]
limit: int = 1000
offset: int = 0

class AdeptIDSkillSearch(BaseTool):
name = "AdeptIDSkillSearch"
description = "Searches for skills and returns the top results."

input = AdeptIDSkillSearchInput

def _run(self, input: AdeptIDSkillSearchInput):
url = "https://api.adept-id.com/v2/skill"
api_key = os.getenv("ADEPTID_API_KEY")
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}" # Replace with your actual API key
}
payload = input.json()
#TODO: check whether this is GET or POST
response = requests.post(url, headers=headers, data=payload)

if response.status_code == 200:
return response.json()
else:
return {"error": response.json()}

class AdeptIDDestinationOccupationRecommendation(BaseTool):
name = "AdeptIDDestinationOccupationRecommendation"
description = "Recommends occupations and career paths to a candidate based on their skills and interests."

input = AdeptIDDestionationOccupationRecommendationInput

def _run(self, input: AdeptIDJobRecommendationInput):
url = "https://api.adept-id.com/v2/recommend-destination-occupation"
api_key = os.getenv("ADEPTID_API_KEY")
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}" # Replace with your actual API key
}
payload = input.json()

response = requests.post(url, headers=headers, data=payload)

if response.status_code == 200:
return response.json()
else:
return {"error": response.json()}

# Define the tool class
class AdeptIDJobRecommendation(BaseTool):
name = "AdeptIDJobRecommendation"
description = "Recommends next step career opportunities for a specific candidate."
description = "Recommends specific jobs for a candidate based on their destination occupation and skills."

input_model = AdeptIDJobRecommendationInput
input = AdeptIDJobRecommendationInput

def _run(self, input: AdeptIDJobRecommendationInput):
url = "https://api.adept-id.com/v2/recommend-destination-occupation"
url = "https://api.adept-id.com/v2/evaluate-jobs"
api_key = os.getenv("ADEPTID_API_KEY")
headers = {
"Content-Type": "application/json",
Expand Down Expand Up @@ -84,5 +140,6 @@ def _run(self, input: AdeptIDJobRecommendationInput):
skill_count=5
)


result = tool.run(input_data)
print(result)
121 changes: 121 additions & 0 deletions backend/tests/notebooks/dev_tools.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'opengpts-py3.10 (Python 3.10.9)' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: '/Users/mattgee/brighthive/opengpts/opengpts-py3.10/bin/python -m pip install ipykernel -U --force-reinstall'"
]
}
],
"source": [
"from opengpts.backend.custom_tools import adeptid as aid"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class AdeptIDSkillSearchInput(BaseModel):\n",
" skills: List[str]\n",
" result_count: int = 1\n",
" offset: int = 1\n",
"\n",
"class AdeptIDDestionationOccupationRecommendationInput(BaseModel):\n",
" candidates: List[Candidate]\n",
" limit: int = 10\n",
" offset: int = 1\n",
"\n",
"class AdeptIDJobRecommendationInput(BaseModel):\n",
" skill_count: int = 0\n",
" destination_jobs: List[str]\n",
" limit: int = 1000\n",
" offset: int = 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#inputs\n",
"\n",
"skills_data = [\"carpentry\", \"communication\", \"cooking\", \"python\"]\n",
"\n",
"job_data = aid.AdeptIDJobRecommendationInput(\n",
" destination_jobs = [\"Carpenter\", \"Computer programmer\"],\n",
")\n",
"\n",
"occupation_data = aid.AdeptIDDestionationOccupationRecommendationInput(\n",
" candidates=[\n",
" aid.Candidate(\n",
" id=\"Piya Gupta\",\n",
" work_history=[\n",
" aid.WorkHistory(title=\"Retail Sales Associate\", start_date=\"12/2019\", end_date=\"4/2022\"),\n",
" aid.WorkHistory(title=\"Graphic Designer\", start_date=\"5/2022\", end_date=\"4/2024\")\n",
" ],\n",
" education=[\n",
" aid.Education(\n",
" level=\"ASSOCIATES\", degree_type=\"ASSOCIATE OF ARTS\", subject=\"Business\",\n",
" start_date=\"09/2020\", end_date=\"06/2022\",\n",
" institution=\"Northern Virgina Community College\", gpa=3.5,\n",
" summary=\"Completed Associate's in Business with a concentration in marketing and high honors graduation\"\n",
" )\n",
" ],\n",
" skills=[\"Graphic Design\", \"Adobe Photoshop\", \"Illustration\", \"Marketing\", \"Logo Design\", \"Merchandising\", \"Writing\"]\n",
" )\n",
" ],\n",
" limit=10,\n",
" offset=1,\n",
" skill_count=5\n",
" )\n",
"\n",
"skills_data = aid.AdeptIDSkillSearchInput(\n",
"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"skill = aid.AdeptIDSkillSearch()\n",
"occupation = aid.AdeptIDDestinationOccupationRecommendation() \n",
"job = aid.AdeptIDJobRecommendation()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "opengpts-py3.10",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 4 additions & 4 deletions frontend/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ export function Layout(props: {
<div className="flex-1 text-sm font-semibold leading-6 text-gray-900 lg:pl-72">
{props.subtitle ? (
<>
OpenGPTs: <span className="font-normal">{props.subtitle}</span>
BrightBot Assistants: <span className="font-normal">{props.subtitle}</span>
</>
) : (
"OpenGPTs"
"BrightBot Assistants"
)}
</div>
<div className="inline-flex items-center rounded-md bg-pink-100 px-2 py-1 text-xs font-medium text-pink-700">
Research Preview: this is unauthenticated and all data can be found.
Do not use with sensitive data
Beta feature: this is a beta admin portal for custom brightbot assistants. Please report any issues to the BrightBot team.

</div>
</div>

Expand Down

0 comments on commit 48ecc75

Please sign in to comment.