Skip to content

Commit

Permalink
Release 0.0.46
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 7, 2023
1 parent bd8f3ee commit 3dbcc18
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "superagent-py"
version = "v0.0.45"
version = "v0.0.46"
description = ""
readme = "README.md"
authors = []
Expand All @@ -10,8 +10,8 @@ packages = [

[tool.poetry.dependencies]
python = "^3.7"
pydantic = "^1.9.2"
httpx = "0.23.3"
pydantic = "^1.9.2"

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
47 changes: 47 additions & 0 deletions src/superagent/resources/agent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ def create_agent(
*,
name: str,
type: str,
description: typing.Optional[str] = OMIT,
avatar_url: typing.Optional[str] = OMIT,
llm: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
has_memory: typing.Optional[bool] = OMIT,
prompt_id: typing.Optional[str] = OMIT,
) -> typing.Any:
_request: typing.Dict[str, typing.Any] = {"name": name, "type": type}
if description is not OMIT:
_request["description"] = description
if avatar_url is not OMIT:
_request["avatarUrl"] = avatar_url
if llm is not OMIT:
_request["llm"] = llm
if has_memory is not OMIT:
Expand All @@ -74,6 +80,23 @@ def create_agent(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def list_library_agents(self) -> typing.Any:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents/library"),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def get_agent(self, agent_id: str) -> typing.Any:
_response = httpx.request(
"GET",
Expand Down Expand Up @@ -193,11 +216,17 @@ async def create_agent(
*,
name: str,
type: str,
description: typing.Optional[str] = OMIT,
avatar_url: typing.Optional[str] = OMIT,
llm: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
has_memory: typing.Optional[bool] = OMIT,
prompt_id: typing.Optional[str] = OMIT,
) -> typing.Any:
_request: typing.Dict[str, typing.Any] = {"name": name, "type": type}
if description is not OMIT:
_request["description"] = description
if avatar_url is not OMIT:
_request["avatarUrl"] = avatar_url
if llm is not OMIT:
_request["llm"] = llm
if has_memory is not OMIT:
Expand All @@ -224,6 +253,24 @@ async def create_agent(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def list_library_agents(self) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents/library"),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def get_agent(self, agent_id: str) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
Expand Down

0 comments on commit 3dbcc18

Please sign in to comment.