From 6601e2cfb64819a25b9726500d1c207e758f01ef Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 06:45:27 +0000 Subject: [PATCH] Release v0.0.26 --- pyproject.toml | 4 +- src/superagent/client.py | 50 ++++++++--------- src/superagent/resources/agent/client.py | 56 ++++++------------- .../resources/agent_documents/client.py | 40 ++++--------- .../resources/agent_tools/client.py | 40 ++++--------- src/superagent/resources/api_token/client.py | 40 ++++--------- src/superagent/resources/auth/client.py | 24 +++----- src/superagent/resources/documents/client.py | 40 ++++--------- src/superagent/resources/prompts/client.py | 48 +++++----------- src/superagent/resources/tools/client.py | 40 ++++--------- src/superagent/resources/traces/client.py | 16 ++---- src/superagent/resources/user/client.py | 24 +++----- 12 files changed, 138 insertions(+), 284 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4b91ae7..e483529 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "superagent-py" -version = "v0.0.25" +version = "v0.0.26" description = "" readme = "README.md" authors = [] @@ -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" diff --git a/src/superagent/client.py b/src/superagent/client.py index dee40d1..5eb1935 100644 --- a/src/superagent/client.py +++ b/src/superagent/client.py @@ -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 @@ -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) diff --git a/src/superagent/resources/agent/client.py b/src/superagent/resources/agent/client.py index 7163206..2e282b7 100644 --- a/src/superagent/resources/agent/client.py +++ b/src/superagent/resources/agent/client.py @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/src/superagent/resources/agent_documents/client.py b/src/superagent/resources/agent_documents/client.py index f3f714c..a1981ba 100644 --- a/src/superagent/resources/agent_documents/client.py +++ b/src/superagent/resources/agent_documents/client.py @@ -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: @@ -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: @@ -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: @@ -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: @@ -99,9 +91,9 @@ 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: @@ -109,9 +101,7 @@ async def list_agent_documents(self, *, expand: typing.Optional[bool] = None) -> "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: @@ -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: @@ -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: @@ -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: diff --git a/src/superagent/resources/agent_tools/client.py b/src/superagent/resources/agent_tools/client.py index 49a8edb..c584188 100644 --- a/src/superagent/resources/agent_tools/client.py +++ b/src/superagent/resources/agent_tools/client.py @@ -15,18 +15,16 @@ class AgentToolsClient: - 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_tools(self, *, expand: typing.Optional[bool] = None) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-tools"), 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: @@ -44,9 +42,7 @@ def create_agent_tool(self, *, agent_id: str, tool_id: str) -> typing.Any: "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-tools"), json=jsonable_encoder({"agentId": agent_id, "toolId": tool_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: @@ -63,9 +59,7 @@ def get_agent_tool(self, agent_tool_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-tools/{agent_tool_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: @@ -82,9 +76,7 @@ def delete_agent_tool(self, agent_tool_id: str) -> typing.Any: _response = httpx.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-tools/{agent_tool_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: @@ -99,9 +91,9 @@ def delete_agent_tool(self, agent_tool_id: str) -> typing.Any: class AsyncAgentToolsClient: - 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_tools(self, *, expand: typing.Optional[bool] = None) -> typing.Any: async with httpx.AsyncClient() as _client: @@ -109,9 +101,7 @@ async def list_agent_tools(self, *, expand: typing.Optional[bool] = None) -> typ "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-tools"), 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: @@ -130,9 +120,7 @@ async def create_agent_tool(self, *, agent_id: str, tool_id: str) -> typing.Any: "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/agent-tools"), json=jsonable_encoder({"agentId": agent_id, "toolId": tool_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: @@ -150,9 +138,7 @@ async def get_agent_tool(self, agent_tool_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-tools/{agent_tool_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: @@ -170,9 +156,7 @@ async def delete_agent_tool(self, agent_tool_id: str) -> typing.Any: _response = await _client.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/agent-tools/{agent_tool_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: diff --git a/src/superagent/resources/api_token/client.py b/src/superagent/resources/api_token/client.py index bc74dbb..3be69c2 100644 --- a/src/superagent/resources/api_token/client.py +++ b/src/superagent/resources/api_token/client.py @@ -15,17 +15,15 @@ class ApiTokenClient: - 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_api_tokens(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/api-tokens"), - 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: @@ -41,9 +39,7 @@ def create_api_token(self, *, description: str) -> typing.Any: "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/api-tokens"), json=jsonable_encoder({"description": description}), - 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: @@ -60,9 +56,7 @@ def get_api_token(self, token_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/api-tokens/{token_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: @@ -79,9 +73,7 @@ def delete_api_token(self, token_id: str) -> typing.Any: _response = httpx.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/api-tokens/{token_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: @@ -96,18 +88,16 @@ def delete_api_token(self, token_id: str) -> typing.Any: class AsyncApiTokenClient: - 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_api_tokens(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/api-tokens"), - 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: @@ -124,9 +114,7 @@ async def create_api_token(self, *, description: str) -> typing.Any: "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/api-tokens"), json=jsonable_encoder({"description": description}), - 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: @@ -144,9 +132,7 @@ async def get_api_token(self, token_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/api-tokens/{token_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: @@ -164,9 +150,7 @@ async def delete_api_token(self, token_id: str) -> typing.Any: _response = await _client.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/api-tokens/{token_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: diff --git a/src/superagent/resources/auth/client.py b/src/superagent/resources/auth/client.py index 0ea7040..01150cc 100644 --- a/src/superagent/resources/auth/client.py +++ b/src/superagent/resources/auth/client.py @@ -18,18 +18,16 @@ class AuthClient: - 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 sign_in(self, *, email: str, password: str) -> typing.Any: _response = httpx.request( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/auth/sign-in"), json=jsonable_encoder({"email": email, "password": password}), - 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: @@ -59,9 +57,7 @@ def sign_up( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/auth/sign-up"), 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: @@ -76,9 +72,9 @@ def sign_up( class AsyncAuthClient: - 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 sign_in(self, *, email: str, password: str) -> typing.Any: async with httpx.AsyncClient() as _client: @@ -86,9 +82,7 @@ async def sign_in(self, *, email: str, password: str) -> typing.Any: "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/auth/sign-in"), json=jsonable_encoder({"email": email, "password": password}), - 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: @@ -119,9 +113,7 @@ async def sign_up( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/auth/sign-up"), 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: diff --git a/src/superagent/resources/documents/client.py b/src/superagent/resources/documents/client.py index bb87dc8..070e9da 100644 --- a/src/superagent/resources/documents/client.py +++ b/src/superagent/resources/documents/client.py @@ -18,17 +18,15 @@ class DocumentsClient: - 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_documents(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), - 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: @@ -63,9 +61,7 @@ def create_document( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), 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: @@ -82,9 +78,7 @@ def get_document(self, document_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{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: @@ -101,9 +95,7 @@ def delete_document(self, document_id: str) -> typing.Any: _response = httpx.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{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: @@ -118,18 +110,16 @@ def delete_document(self, document_id: str) -> typing.Any: class AsyncDocumentsClient: - 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_documents(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), - 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: @@ -165,9 +155,7 @@ async def create_document( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), 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: @@ -185,9 +173,7 @@ async def get_document(self, document_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{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: @@ -205,9 +191,7 @@ async def delete_document(self, document_id: str) -> typing.Any: _response = await _client.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{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: diff --git a/src/superagent/resources/prompts/client.py b/src/superagent/resources/prompts/client.py index ded584c..8a81d68 100644 --- a/src/superagent/resources/prompts/client.py +++ b/src/superagent/resources/prompts/client.py @@ -15,17 +15,15 @@ class PromptsClient: - 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_prompts(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/prompts"), - 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: @@ -41,9 +39,7 @@ def create_a_prompt(self, *, name: str, input_variables: typing.List[typing.Any] "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/prompts"), json=jsonable_encoder({"name": name, "input_variables": input_variables, "template": template}), - 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: @@ -60,9 +56,7 @@ def get_prompt(self, prompt_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: @@ -80,9 +74,7 @@ def patch_prompt(self, prompt_id: str, *, request: typing.Dict[str, typing.Any]) "PATCH", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: @@ -99,9 +91,7 @@ def delete_prompt(self, prompt_id: str) -> typing.Any: _response = httpx.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: @@ -116,18 +106,16 @@ def delete_prompt(self, prompt_id: str) -> typing.Any: class AsyncPromptsClient: - 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_prompts(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/prompts"), - 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: @@ -146,9 +134,7 @@ async def create_a_prompt( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/prompts"), json=jsonable_encoder({"name": name, "input_variables": input_variables, "template": template}), - 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: @@ -166,9 +152,7 @@ async def get_prompt(self, prompt_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: @@ -187,9 +171,7 @@ async def patch_prompt(self, prompt_id: str, *, request: typing.Dict[str, typing "PATCH", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: @@ -207,9 +189,7 @@ async def delete_prompt(self, prompt_id: str) -> typing.Any: _response = await _client.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/prompts/{prompt_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: diff --git a/src/superagent/resources/tools/client.py b/src/superagent/resources/tools/client.py index ec511df..b23169b 100644 --- a/src/superagent/resources/tools/client.py +++ b/src/superagent/resources/tools/client.py @@ -18,17 +18,15 @@ class ToolsClient: - 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_tools(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), - 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: @@ -56,9 +54,7 @@ def create_a_tool( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), 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: @@ -75,9 +71,7 @@ def get_tool(self, tool_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/tools/{tool_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: @@ -94,9 +88,7 @@ def delete_tool(self, tool_id: str) -> typing.Any: _response = httpx.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/tools/{tool_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: @@ -111,18 +103,16 @@ def delete_tool(self, tool_id: str) -> typing.Any: class AsyncToolsClient: - 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_tools(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), - 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: @@ -151,9 +141,7 @@ async def create_a_tool( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), 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: @@ -171,9 +159,7 @@ async def get_tool(self, tool_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/tools/{tool_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: @@ -191,9 +177,7 @@ async def delete_tool(self, tool_id: str) -> typing.Any: _response = await _client.request( "DELETE", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/tools/{tool_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: diff --git a/src/superagent/resources/traces/client.py b/src/superagent/resources/traces/client.py index 960e97f..bc80c17 100644 --- a/src/superagent/resources/traces/client.py +++ b/src/superagent/resources/traces/client.py @@ -12,17 +12,15 @@ class TracesClient: - 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_traces(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/traces"), - 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: @@ -35,18 +33,16 @@ def list_agent_traces(self) -> typing.Any: class AsyncTracesClient: - 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_traces(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/traces"), - 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: diff --git a/src/superagent/resources/user/client.py b/src/superagent/resources/user/client.py index 59ee2f7..e399a2f 100644 --- a/src/superagent/resources/user/client.py +++ b/src/superagent/resources/user/client.py @@ -14,17 +14,15 @@ class UserClient: - 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 read_user_me(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/users/me"), - 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: @@ -39,9 +37,7 @@ def read_user(self, user_id: str) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/users/{user_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: @@ -56,18 +52,16 @@ def read_user(self, user_id: str) -> typing.Any: class AsyncUserClient: - 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 read_user_me(self) -> typing.Any: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/users/me"), - 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: @@ -83,9 +77,7 @@ async def read_user(self, user_id: str) -> typing.Any: _response = await _client.request( "GET", urllib.parse.urljoin(f"{self._environment}/", f"api/v1/users/{user_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: