Create client for Tools API (#1348)

This commit creates a class for the new Tools API. It extracts common
methods from crewai.cli.deploy.api.CrewAPI to a parent class.
This commit is contained in:
Vini Brasil
2024-09-25 12:37:54 -03:00
committed by GitHub
parent f5098e7e45
commit effb7efc37
7 changed files with 180 additions and 53 deletions

View File

View File

@@ -0,0 +1,26 @@
from typing import Optional
from crewai.cli.plus_api import PlusAPI
class ToolsAPI(PlusAPI):
RESOURCE = "/crewai_plus/api/v1/tools"
def get(self, handle: str):
return self._make_request("GET", f"{self.RESOURCE}/{handle}")
def publish(
self,
handle: str,
public: bool,
version: str,
description: Optional[str],
encoded_file: str,
):
params = {
"handle": handle,
"public": public,
"version": version,
"file": encoded_file,
"description": description,
}
return self._make_request("POST", f"{self.RESOURCE}", json=params)