Skip to content

Commit

Permalink
updated the AdpetID tools
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgee committed Aug 6, 2024
1 parent 48ecc75 commit e87b286
Show file tree
Hide file tree
Showing 16 changed files with 3,844 additions and 1,516 deletions.
8 changes: 8 additions & 0 deletions backend/app/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
RETRIEVAL_DESCRIPTION,
TOOLS,
ActionServer,
AdeptID,
Arxiv,
AvailableTools,
Connery,
Expand All @@ -42,10 +43,14 @@
YouSearch,
get_retrieval_tool,
get_retriever,
Skillup,
Skillup_Jobs,
Skillup_Training
)

Tool = Union[
ActionServer,
AdeptID,
Connery,
DDGSearch,
Arxiv,
Expand All @@ -57,6 +62,9 @@
Tavily,
TavilyAnswer,
Retrieval,
Skillup,
Skillup_Jobs,
Skillup_Training,
DallE,
]

Expand Down
51 changes: 50 additions & 1 deletion backend/app/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class AvailableTools(str, Enum):
WIKIPEDIA = "wikipedia"
DALL_E = "dall_e"
ADEPTID = "adeptid"
SKILLUP = "skillup"
SKILLUP_TRAINING = "skillup_training"
SKILLUP_JOBS = "skillup_jobs"


class ToolConfig(TypedDict):
Expand Down Expand Up @@ -102,7 +105,7 @@ class AdeptID(BaseTool):
name: str = Field("AdeptID API", const=True)
description: str = Field(
(
"Get personalized career paths and job recommendations from"
"Get personalized career paths and job recommendations from "
"[AdeptID](https://adeptid.com)"
),
const=True
Expand Down Expand Up @@ -180,6 +183,36 @@ class Wikipedia(BaseTool):
)


class Skillup(BaseTool):
type: AvailableTools = Field(AvailableTools.SKILLUP, const=True)
name: str = Field("Skillup", const=True)
description: str = Field(
(
"Searches [Skillup](https://www.skillup.com/)."
"This is a tool for skillup training opportunities and jobs"
),
const=True)

class Skillup_Training(BaseTool):
type: AvailableTools = Field(AvailableTools.SKILLUP_TRAINING, const=True)
name: str = Field("Skillup Training", const=True)
description: str = Field(
(
"Searches [Skillup](https://www.skillup.com/)."
"This is a tool for skillup training opportunities"
),
const=True)

class Skillup_Jobs(BaseTool):
type: AvailableTools = Field(AvailableTools.SKILLUP_JOBS, const=True)
name: str = Field("Skillup Jobs", const=True)
description: str = Field(
(
"Searches [Skillup](https://www.skillup.com/)."
"This is a tool for skillup jobs"
),
const=True)

class Tavily(BaseTool):
type: AvailableTools = Field(AvailableTools.TAVILY, const=True)
name: str = Field("Search (Tavily)", const=True)
Expand Down Expand Up @@ -257,6 +290,10 @@ def _get_you_search():
"Searches for documents using You.com",
)

#add retriever tool for skillup training

#add retriever tool for skillup jobs


@lru_cache(maxsize=1)
def _get_sec_filings():
Expand Down Expand Up @@ -334,6 +371,16 @@ def _get_adeptID_tools(**kwargs: ActionServerConfig):
tools = toolkit.get_tools()
return tools

def _get_skillup_training():
return create_retriever_tool(
WikipediaRetriever(), "wikipedia", "Search for training and jobs on Wikipedia"
)

def _get_skillup_jobs():
return create_retriever_tool(
WikipediaRetriever(), "wikipedia", "Search for training and jobs on Wikipedia"
)

TOOLS = {
AvailableTools.ACTION_SERVER: _get_action_server,
AvailableTools.CONNERY: _get_connery_actions,
Expand All @@ -348,4 +395,6 @@ def _get_adeptID_tools(**kwargs: ActionServerConfig):
AvailableTools.TAVILY_ANSWER: _get_tavily_answer,
AvailableTools.DALL_E: _get_dalle_tools,
AvailableTools.ADEPTID: _get_adeptID_tools,
AvailableTools.SKILLUP_TRAINING: _get_skillup_training,
AvailableTools.SKILLUP_JOBS: _get_skillup_jobs,
}
2 changes: 1 addition & 1 deletion backend/custom_tools/adeptid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List
import os

ADEPT_ID_API_KEY =
ADEPT_ID_API_KEY = os.getenv("ADEPTID_API_KEY")

# Define the input schema for the tool
class WorkHistory(BaseModel):
Expand Down
Empty file added backend/custom_tools/skillup.py
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS thread;
DROP TABLE IF EXISTS assistant;
DROP TABLE IF EXISTS checkpoints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

CREATE TABLE IF NOT EXISTS assistant (
assistant_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
config JSON NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
public BOOLEAN NOT NULL
);

CREATE TABLE IF NOT EXISTS thread (
thread_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
assistant_id UUID REFERENCES assistant(assistant_id) ON DELETE SET NULL,
user_id VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
);

CREATE TABLE IF NOT EXISTS checkpoints (
thread_id TEXT PRIMARY KEY,
checkpoint BYTEA
);
5 changes: 5 additions & 0 deletions backend/migrations/000002_checkpoints_update_schema.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE checkpoints
DROP CONSTRAINT IF EXISTS checkpoints_pkey,
ADD PRIMARY KEY (thread_id),
DROP COLUMN IF EXISTS thread_ts,
DROP COLUMN IF EXISTS parent_ts;
11 changes: 11 additions & 0 deletions backend/migrations/000002_checkpoints_update_schema.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALTER TABLE checkpoints
ADD COLUMN IF NOT EXISTS thread_ts TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS parent_ts TIMESTAMPTZ;

UPDATE checkpoints
SET thread_ts = CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
WHERE thread_ts IS NULL;

ALTER TABLE checkpoints
DROP CONSTRAINT IF EXISTS checkpoints_pkey,
ADD PRIMARY KEY (thread_id, thread_ts)
9 changes: 9 additions & 0 deletions backend/migrations/000003_create_user.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALTER TABLE assistant
DROP CONSTRAINT fk_assistant_user_id,
ALTER COLUMN user_id TYPE VARCHAR USING (user_id::text);

ALTER TABLE thread
DROP CONSTRAINT fk_thread_user_id,
ALTER COLUMN user_id TYPE VARCHAR USING (user_id::text);

DROP TABLE IF EXISTS "user";
25 changes: 25 additions & 0 deletions backend/migrations/000003_create_user.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE IF NOT EXISTS "user" (
user_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
sub VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
);

INSERT INTO "user" (user_id, sub)
SELECT DISTINCT user_id::uuid, user_id
FROM assistant
WHERE user_id IS NOT NULL
ON CONFLICT (user_id) DO NOTHING;

INSERT INTO "user" (user_id, sub)
SELECT DISTINCT user_id::uuid, user_id
FROM thread
WHERE user_id IS NOT NULL
ON CONFLICT (user_id) DO NOTHING;

ALTER TABLE assistant
ALTER COLUMN user_id TYPE UUID USING (user_id::UUID),
ADD CONSTRAINT fk_assistant_user_id FOREIGN KEY (user_id) REFERENCES "user"(user_id);

ALTER TABLE thread
ALTER COLUMN user_id TYPE UUID USING (user_id::UUID),
ADD CONSTRAINT fk_thread_user_id FOREIGN KEY (user_id) REFERENCES "user"(user_id);
2 changes: 2 additions & 0 deletions backend/migrations/000004_add_metadata_to_thread.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE thread
DROP COLUMN metadata;
9 changes: 9 additions & 0 deletions backend/migrations/000004_add_metadata_to_thread.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALTER TABLE thread
ADD COLUMN metadata JSONB;

UPDATE thread
SET metadata = json_build_object(
'assistant_type', (SELECT config->'configurable'->>'type'
FROM assistant
WHERE assistant.assistant_id = thread.assistant_id)
);
Loading

0 comments on commit e87b286

Please sign in to comment.