From 21026a0647e5f9b5302a1cfc58329e7322ad717e Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 12 Jul 2023 22:09:55 +0000 Subject: [PATCH] Release v0.0.33 --- 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, 284 insertions(+), 138 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0ed25f5..b02c663 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "superagent-py" -version = "v0.0.32" +version = "v0.0.33" 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 5eb1935..dee40d1 100644 --- a/src/superagent/client.py +++ b/src/superagent/client.py @@ -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 @@ -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) diff --git a/src/superagent/resources/agent/client.py b/src/superagent/resources/agent/client.py index 2e282b7..7163206 100644 --- a/src/superagent/resources/agent/client.py +++ b/src/superagent/resources/agent/client.py @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/src/superagent/resources/agent_documents/client.py b/src/superagent/resources/agent_documents/client.py index a1981ba..f3f714c 100644 --- a/src/superagent/resources/agent_documents/client.py +++ b/src/superagent/resources/agent_documents/client.py @@ -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: @@ -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: @@ -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: @@ -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: @@ -91,9 +99,9 @@ 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: @@ -101,7 +109,9 @@ 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({"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: @@ -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: @@ -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: @@ -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: diff --git a/src/superagent/resources/agent_tools/client.py b/src/superagent/resources/agent_tools/client.py index c584188..49a8edb 100644 --- a/src/superagent/resources/agent_tools/client.py +++ b/src/superagent/resources/agent_tools/client.py @@ -15,16 +15,18 @@ class AgentToolsClient: - 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_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({"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: @@ -42,7 +44,9 @@ 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({"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: @@ -59,7 +63,9 @@ 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({"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: @@ -76,7 +82,9 @@ 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({"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: @@ -91,9 +99,9 @@ def delete_agent_tool(self, agent_tool_id: str) -> typing.Any: class AsyncAgentToolsClient: - 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_tools(self, *, expand: typing.Optional[bool] = None) -> typing.Any: async with httpx.AsyncClient() as _client: @@ -101,7 +109,9 @@ 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({"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: @@ -120,7 +130,9 @@ 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({"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: @@ -138,7 +150,9 @@ 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({"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: @@ -156,7 +170,9 @@ 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({"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: diff --git a/src/superagent/resources/api_token/client.py b/src/superagent/resources/api_token/client.py index 3be69c2..bc74dbb 100644 --- a/src/superagent/resources/api_token/client.py +++ b/src/superagent/resources/api_token/client.py @@ -15,15 +15,17 @@ class ApiTokenClient: - 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_api_tokens(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/api-tokens"), - 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: @@ -39,7 +41,9 @@ 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({"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: @@ -56,7 +60,9 @@ 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({"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: @@ -73,7 +79,9 @@ 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({"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: @@ -88,16 +96,18 @@ def delete_api_token(self, token_id: str) -> typing.Any: class AsyncApiTokenClient: - 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_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({"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: @@ -114,7 +124,9 @@ 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({"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: @@ -132,7 +144,9 @@ 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({"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: @@ -150,7 +164,9 @@ 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({"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: diff --git a/src/superagent/resources/auth/client.py b/src/superagent/resources/auth/client.py index 01150cc..0ea7040 100644 --- a/src/superagent/resources/auth/client.py +++ b/src/superagent/resources/auth/client.py @@ -18,16 +18,18 @@ class AuthClient: - 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 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({"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: @@ -57,7 +59,9 @@ def sign_up( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/auth/sign-up"), 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: @@ -72,9 +76,9 @@ def sign_up( class AsyncAuthClient: - 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 sign_in(self, *, email: str, password: str) -> typing.Any: async with httpx.AsyncClient() as _client: @@ -82,7 +86,9 @@ 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({"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: @@ -113,7 +119,9 @@ 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({"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: diff --git a/src/superagent/resources/documents/client.py b/src/superagent/resources/documents/client.py index 070e9da..bb87dc8 100644 --- a/src/superagent/resources/documents/client.py +++ b/src/superagent/resources/documents/client.py @@ -18,15 +18,17 @@ class DocumentsClient: - 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_documents(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), - 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: @@ -61,7 +63,9 @@ def create_document( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), 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: @@ -78,7 +82,9 @@ 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({"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: @@ -95,7 +101,9 @@ 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({"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: @@ -110,16 +118,18 @@ def delete_document(self, document_id: str) -> typing.Any: class AsyncDocumentsClient: - 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_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({"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: @@ -155,7 +165,9 @@ async def create_document( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/documents"), 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: @@ -173,7 +185,9 @@ 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({"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: @@ -191,7 +205,9 @@ 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({"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: diff --git a/src/superagent/resources/prompts/client.py b/src/superagent/resources/prompts/client.py index 8a81d68..ded584c 100644 --- a/src/superagent/resources/prompts/client.py +++ b/src/superagent/resources/prompts/client.py @@ -15,15 +15,17 @@ class PromptsClient: - 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_prompts(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/prompts"), - 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: @@ -39,7 +41,9 @@ 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({"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: @@ -56,7 +60,9 @@ 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({"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: @@ -74,7 +80,9 @@ 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({"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: @@ -91,7 +99,9 @@ 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({"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: @@ -106,16 +116,18 @@ def delete_prompt(self, prompt_id: str) -> typing.Any: class AsyncPromptsClient: - 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_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({"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: @@ -134,7 +146,9 @@ 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({"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: @@ -152,7 +166,9 @@ 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({"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: @@ -171,7 +187,9 @@ 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({"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: @@ -189,7 +207,9 @@ 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({"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: diff --git a/src/superagent/resources/tools/client.py b/src/superagent/resources/tools/client.py index b23169b..ec511df 100644 --- a/src/superagent/resources/tools/client.py +++ b/src/superagent/resources/tools/client.py @@ -18,15 +18,17 @@ class ToolsClient: - 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_tools(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), - 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: @@ -54,7 +56,9 @@ def create_a_tool( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), 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: @@ -71,7 +75,9 @@ 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({"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: @@ -88,7 +94,9 @@ 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({"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: @@ -103,16 +111,18 @@ def delete_tool(self, tool_id: str) -> typing.Any: class AsyncToolsClient: - 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_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({"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: @@ -141,7 +151,9 @@ async def create_a_tool( "POST", urllib.parse.urljoin(f"{self._environment}/", "api/v1/tools"), 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: @@ -159,7 +171,9 @@ 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({"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: @@ -177,7 +191,9 @@ 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({"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: diff --git a/src/superagent/resources/traces/client.py b/src/superagent/resources/traces/client.py index bc80c17..960e97f 100644 --- a/src/superagent/resources/traces/client.py +++ b/src/superagent/resources/traces/client.py @@ -12,15 +12,17 @@ class TracesClient: - 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_traces(self) -> typing.Any: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment}/", "api/v1/traces"), - 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: @@ -33,16 +35,18 @@ def list_agent_traces(self) -> typing.Any: class AsyncTracesClient: - 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_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({"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: diff --git a/src/superagent/resources/user/client.py b/src/superagent/resources/user/client.py index e399a2f..59ee2f7 100644 --- a/src/superagent/resources/user/client.py +++ b/src/superagent/resources/user/client.py @@ -14,15 +14,17 @@ class UserClient: - 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 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({"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: @@ -37,7 +39,9 @@ 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({"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: @@ -52,16 +56,18 @@ def read_user(self, user_id: str) -> typing.Any: class AsyncUserClient: - 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 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({"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: @@ -77,7 +83,9 @@ 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({"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: