Skip to content

Commit

Permalink
Release v0.0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jul 12, 2023
1 parent da8781a commit 21026a0
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 138 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.32"
version = "v0.0.33"
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
50 changes: 26 additions & 24 deletions src/superagent/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file was auto-generated by Fern from our API Definition.

import typing

from .resources.agent.client import AgentClient, AsyncAgentClient
from .resources.agent_documents.client import AgentDocumentsClient, AsyncAgentDocumentsClient
from .resources.agent_tools.client import AgentToolsClient, AsyncAgentToolsClient
Expand All @@ -13,32 +15,32 @@


class Superagent:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self.agent = AgentClient(environment=self._environment, api_key=self.api_key)
self.agent_documents = AgentDocumentsClient(environment=self._environment, api_key=self.api_key)
self.agent_tools = AgentToolsClient(environment=self._environment, api_key=self.api_key)
self.auth = AuthClient(environment=self._environment, api_key=self.api_key)
self.user = UserClient(environment=self._environment, api_key=self.api_key)
self.api_token = ApiTokenClient(environment=self._environment, api_key=self.api_key)
self.documents = DocumentsClient(environment=self._environment, api_key=self.api_key)
self.prompts = PromptsClient(environment=self._environment, api_key=self.api_key)
self.tools = ToolsClient(environment=self._environment, api_key=self.api_key)
self.traces = TracesClient(environment=self._environment, api_key=self.api_key)
self._token = token
self.agent = AgentClient(environment=self._environment, token=self._token)
self.agent_documents = AgentDocumentsClient(environment=self._environment, token=self._token)
self.agent_tools = AgentToolsClient(environment=self._environment, token=self._token)
self.auth = AuthClient(environment=self._environment, token=self._token)
self.user = UserClient(environment=self._environment, token=self._token)
self.api_token = ApiTokenClient(environment=self._environment, token=self._token)
self.documents = DocumentsClient(environment=self._environment, token=self._token)
self.prompts = PromptsClient(environment=self._environment, token=self._token)
self.tools = ToolsClient(environment=self._environment, token=self._token)
self.traces = TracesClient(environment=self._environment, token=self._token)


class AsyncSuperagent:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self.agent = AsyncAgentClient(environment=self._environment, api_key=self.api_key)
self.agent_documents = AsyncAgentDocumentsClient(environment=self._environment, api_key=self.api_key)
self.agent_tools = AsyncAgentToolsClient(environment=self._environment, api_key=self.api_key)
self.auth = AsyncAuthClient(environment=self._environment, api_key=self.api_key)
self.user = AsyncUserClient(environment=self._environment, api_key=self.api_key)
self.api_token = AsyncApiTokenClient(environment=self._environment, api_key=self.api_key)
self.documents = AsyncDocumentsClient(environment=self._environment, api_key=self.api_key)
self.prompts = AsyncPromptsClient(environment=self._environment, api_key=self.api_key)
self.tools = AsyncToolsClient(environment=self._environment, api_key=self.api_key)
self.traces = AsyncTracesClient(environment=self._environment, api_key=self.api_key)
self._token = token
self.agent = AsyncAgentClient(environment=self._environment, token=self._token)
self.agent_documents = AsyncAgentDocumentsClient(environment=self._environment, token=self._token)
self.agent_tools = AsyncAgentToolsClient(environment=self._environment, token=self._token)
self.auth = AsyncAuthClient(environment=self._environment, token=self._token)
self.user = AsyncUserClient(environment=self._environment, token=self._token)
self.api_token = AsyncApiTokenClient(environment=self._environment, token=self._token)
self.documents = AsyncDocumentsClient(environment=self._environment, token=self._token)
self.prompts = AsyncPromptsClient(environment=self._environment, token=self._token)
self.tools = AsyncToolsClient(environment=self._environment, token=self._token)
self.traces = AsyncTracesClient(environment=self._environment, token=self._token)
56 changes: 40 additions & 16 deletions src/superagent/resources/agent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@


class AgentClient:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self._token = token

def list_all_agents(self) -> typing.Any:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand Down Expand Up @@ -57,7 +59,9 @@ def create_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -74,7 +78,9 @@ def get_agent(self, agent_id: str) -> typing.Any:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -92,7 +98,9 @@ def patch_agent(self, agent_id: str, *, request: typing.Dict[str, typing.Any]) -
"PATCH",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
json=jsonable_encoder(request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -109,7 +117,9 @@ def delete_agent(self, agent_id: str) -> typing.Any:
_response = httpx.request(
"DELETE",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -132,7 +142,9 @@ def prompt_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}/predict"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -147,16 +159,18 @@ def prompt_agent(


class AsyncAgentClient:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self._token = token

async def list_all_agents(self) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand Down Expand Up @@ -188,7 +202,9 @@ async def create_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -206,7 +222,9 @@ async def get_agent(self, agent_id: str) -> typing.Any:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -225,7 +243,9 @@ async def patch_agent(self, agent_id: str, *, request: typing.Dict[str, typing.A
"PATCH",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
json=jsonable_encoder(request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -243,7 +263,9 @@ async def delete_agent(self, agent_id: str) -> typing.Any:
_response = await _client.request(
"DELETE",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -267,7 +289,9 @@ async def prompt_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agents/{agent_id}/predict"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand Down
40 changes: 28 additions & 12 deletions src/superagent/resources/agent_documents/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@


class AgentDocumentsClient:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self._token = token

def list_agent_documents(self, *, expand: typing.Optional[bool] = None) -> typing.Any:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-documents"),
params={"expand": expand},
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -42,7 +44,9 @@ def create_agent_document(self, *, agent_id: str, document_id: str) -> typing.An
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-documents"),
json=jsonable_encoder({"agentId": agent_id, "documentId": document_id}),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -59,7 +63,9 @@ def get_agent_document(self, agent_document_id: str) -> typing.Any:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-documents/{agent_document_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -76,7 +82,9 @@ def delete_agent_document(self, agent_document_id: str) -> typing.Any:
_response = httpx.request(
"DELETE",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-documents/{agent_document_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -91,17 +99,19 @@ def delete_agent_document(self, agent_document_id: str) -> typing.Any:


class AsyncAgentDocumentsClient:
def __init__(self, *, environment: str, api_key: str):
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
self._environment = environment
self.api_key = api_key
self._token = token

async def list_agent_documents(self, *, expand: typing.Optional[bool] = None) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-documents"),
params={"expand": expand},
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -120,7 +130,9 @@ async def create_agent_document(self, *, agent_id: str, document_id: str) -> typ
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-documents"),
json=jsonable_encoder({"agentId": agent_id, "documentId": document_id}),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -138,7 +150,9 @@ async def get_agent_document(self, agent_document_id: str) -> typing.Any:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-documents/{agent_document_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand All @@ -156,7 +170,9 @@ async def delete_agent_document(self, agent_document_id: str) -> typing.Any:
_response = await _client.request(
"DELETE",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-documents/{agent_document_id}"),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
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:
Expand Down
Loading

0 comments on commit 21026a0

Please sign in to comment.