Skip to content

Commit

Permalink
Release v0.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jun 29, 2023
1 parent cfebdf6 commit 6601e2c
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 284 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.25"
version = "v0.0.26"
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: 24 additions & 26 deletions src/superagent/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# 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 @@ -15,32 +13,32 @@


class Superagent:
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
def __init__(self, *, environment: str, api_key: str):
self._environment = environment
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)
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)


class AsyncSuperagent:
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
def __init__(self, *, environment: str, api_key: str):
self._environment = environment
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)
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)
56 changes: 16 additions & 40 deletions src/superagent/resources/agent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@


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

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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand Down Expand Up @@ -59,9 +57,7 @@ def create_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -78,9 +74,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -98,9 +92,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -117,9 +109,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -142,9 +132,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -159,18 +147,16 @@ def prompt_agent(


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

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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand Down Expand Up @@ -202,9 +188,7 @@ async def create_agent(
"POST",
urllib.parse.urljoin(f"{self._environment}/", "api/v1/agents"),
json=jsonable_encoder(_request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -222,9 +206,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -243,9 +225,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -263,9 +243,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -289,9 +267,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand Down
40 changes: 12 additions & 28 deletions src/superagent/resources/agent_documents/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@


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

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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -44,9 +42,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -63,9 +59,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -82,9 +76,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -99,19 +91,17 @@ def delete_agent_document(self, agent_document_id: str) -> typing.Any:


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

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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -130,9 +120,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -150,9 +138,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand All @@ -170,9 +156,7 @@ 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(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
headers=remove_none_from_headers({"X_SUPERAGENT_API_KEY": self.api_key}),
timeout=60,
)
if 200 <= _response.status_code < 300:
Expand Down
Loading

0 comments on commit 6601e2c

Please sign in to comment.