Skip to content

Commit

Permalink
Replacing worker node to agent node in toolset
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-kmt committed Dec 30, 2024
1 parent 4c2fbf7 commit b002389
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions naptha_sdk/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

class Toolset:
def __init__(self,
worker_node_url,
agent_node_url,
agent_id,
*args,
**kwargs
):

self.agent_id = agent_id
self.worker_node_url = worker_node_url
self.agent_node_url = agent_node_url

async def load_or_add_tool_repo_to_toolset(self, toolset_name, repo_url):
logger.info(f"Loading tool repo to toolset on worker node {self.worker_node_url}")
logger.info(f"Loading tool repo to toolset on worker node {self.agent_node_url}")
try:
request = ToolsetLoadRepoRequest(
agent_id=self.agent_id,
Expand All @@ -32,7 +32,7 @@ async def load_or_add_tool_repo_to_toolset(self, toolset_name, repo_url):

async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
load_repo_response = await client.post(
f"{self.worker_node_url}/tool/add_tool_repo_to_toolset",
f"{self.agent_node_url}/tool/add_tool_repo_to_toolset",
json=request.model_dump()
)
load_repo_response.raise_for_status()
Expand All @@ -45,7 +45,7 @@ async def load_or_add_tool_repo_to_toolset(self, toolset_name, repo_url):
raise

async def load_or_add_tool_repo_to_toolset_from_hub(self, toolset_name, toolset_hub_id):
logger.info(f"Loading tool repo to toolset on worker node {self.worker_node_url}")
logger.info(f"Loading tool repo to toolset on worker node {self.agent_node_url}")

# pull toolset from hub
hub_url = os.getenv("HUB_URL", None)
Expand Down Expand Up @@ -73,7 +73,7 @@ async def load_or_add_tool_repo_to_toolset_from_hub(self, toolset_name, toolset_

async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
load_repo_response = await client.post(
f"{self.worker_node_url}/tool/add_tool_repo_to_toolset",
f"{self.agent_node_url}/tool/add_tool_repo_to_toolset",
json=request.model_dump()
)
load_repo_response.raise_for_status()
Expand All @@ -93,7 +93,7 @@ async def get_toolset_list(self):
async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
# Send agent_id as a query parameter
toolset_list_response = await client.post(
f"{self.worker_node_url}/tool/get_toolset_list",
f"{self.agent_node_url}/tool/get_toolset_list",
json=request.model_dump()
)
toolset_list_response.raise_for_status()
Expand All @@ -114,7 +114,7 @@ async def set_toolset(self, toolset_name):

async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
toolset_response = await client.post(
f"{self.worker_node_url}/tool/set_toolset",
f"{self.agent_node_url}/tool/set_toolset",
json=request.model_dump()
)
toolset_response.raise_for_status()
Expand All @@ -139,7 +139,7 @@ async def get_current_toolset(self):

async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
toolset_list_response = await client.post(
f"{self.worker_node_url}/tool/get_current_toolset",
f"{self.agent_node_url}/tool/get_current_toolset",
json=request.model_dump()
)
toolset_list_response.raise_for_status()
Expand Down Expand Up @@ -168,7 +168,7 @@ async def run_tool(self, toolset_name, tool_name, params):

async with httpx.AsyncClient(timeout=HTTP_TIMEOUT) as client:
tool_run_response = await client.post(
f"{self.worker_node_url}/tool/run_tool",
f"{self.agent_node_url}/tool/run_tool",
json=request.model_dump()
)
tool_run_response.raise_for_status()
Expand Down

0 comments on commit b002389

Please sign in to comment.