Skip to content

Commit

Permalink
Release 0.0.54
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 20, 2023
1 parent c64aabf commit 13d63d8
Show file tree
Hide file tree
Showing 23 changed files with 1,275 additions and 782 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@ jobs:
run: poetry install
- name: Compile
run: poetry run mypy .
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Install dependencies
run: poetry install
- name: Test
run: poetry run pytest .

publish:
needs: [ compile ]
needs: [compile, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "superagent-py"
version = "v0.0.52"
version = "v0.0.54"
description = ""
readme = "README.md"
authors = []
Expand All @@ -10,11 +10,12 @@ packages = [

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

[tool.poetry.dev-dependencies]
mypy = "0.971"
pytest = "^7.4.0"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion src/superagent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from .types import HttpValidationError, ValidationError, ValidationErrorLocItem
from .errors import UnprocessableEntityError
from .resources import (
agent,
Expand All @@ -14,7 +15,6 @@
traces,
user,
)
from .types import HttpValidationError, ValidationError, ValidationErrorLocItem

__all__ = [
"HttpValidationError",
Expand Down
73 changes: 45 additions & 28 deletions src/superagent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import typing

import httpx

from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .resources.agent.client import AgentClient, AsyncAgentClient
from .resources.agent_documents.client import AgentDocumentsClient, AsyncAgentDocumentsClient
from .resources.agent_tools.client import AgentToolsClient, AsyncAgentToolsClient
Expand All @@ -16,34 +19,48 @@


class Superagent:
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
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.tags = TagsClient(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)
def __init__(
self,
*,
base_url: str,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
timeout: typing.Optional[float] = 60
):
self._client_wrapper = SyncClientWrapper(
base_url=base_url, token=token, httpx_client=httpx.Client(timeout=timeout)
)
self.agent = AgentClient(client_wrapper=self._client_wrapper)
self.agent_documents = AgentDocumentsClient(client_wrapper=self._client_wrapper)
self.tags = TagsClient(client_wrapper=self._client_wrapper)
self.agent_tools = AgentToolsClient(client_wrapper=self._client_wrapper)
self.auth = AuthClient(client_wrapper=self._client_wrapper)
self.user = UserClient(client_wrapper=self._client_wrapper)
self.api_token = ApiTokenClient(client_wrapper=self._client_wrapper)
self.documents = DocumentsClient(client_wrapper=self._client_wrapper)
self.prompts = PromptsClient(client_wrapper=self._client_wrapper)
self.tools = ToolsClient(client_wrapper=self._client_wrapper)
self.traces = TracesClient(client_wrapper=self._client_wrapper)


class AsyncSuperagent:
def __init__(self, *, environment: str, token: typing.Optional[str] = None):
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.tags = AsyncTagsClient(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)
def __init__(
self,
*,
base_url: str,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
timeout: typing.Optional[float] = 60
):
self._client_wrapper = AsyncClientWrapper(
base_url=base_url, token=token, httpx_client=httpx.AsyncClient(timeout=timeout)
)
self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
self.agent_documents = AsyncAgentDocumentsClient(client_wrapper=self._client_wrapper)
self.tags = AsyncTagsClient(client_wrapper=self._client_wrapper)
self.agent_tools = AsyncAgentToolsClient(client_wrapper=self._client_wrapper)
self.auth = AsyncAuthClient(client_wrapper=self._client_wrapper)
self.user = AsyncUserClient(client_wrapper=self._client_wrapper)
self.api_token = AsyncApiTokenClient(client_wrapper=self._client_wrapper)
self.documents = AsyncDocumentsClient(client_wrapper=self._client_wrapper)
self.prompts = AsyncPromptsClient(client_wrapper=self._client_wrapper)
self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
self.traces = AsyncTracesClient(client_wrapper=self._client_wrapper)
13 changes: 11 additions & 2 deletions src/superagent/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# This file was auto-generated by Fern from our API Definition.

from .api_error import ApiError
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
from .datetime_utils import serialize_datetime
from .jsonable_encoder import jsonable_encoder
from .remove_none_from_headers import remove_none_from_headers
from .remove_none_from_dict import remove_none_from_dict

__all__ = ["ApiError", "jsonable_encoder", "remove_none_from_headers", "serialize_datetime"]
__all__ = [
"ApiError",
"AsyncClientWrapper",
"BaseClientWrapper",
"SyncClientWrapper",
"jsonable_encoder",
"remove_none_from_dict",
"serialize_datetime",
]
55 changes: 55 additions & 0 deletions src/superagent/core/client_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file was auto-generated by Fern from our API Definition.

import typing

import httpx


class BaseClientWrapper:
def __init__(self, *, token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str):
self._token = token
self._base_url = base_url

def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "superagent-py",
"X-Fern-SDK-Version": "v0.0.54",
}
token = self._get_token()
if token is not None:
headers["Authorization"] = f"Bearer {token}"
return headers

def _get_token(self) -> typing.Optional[str]:
if isinstance(self._token, str) or self._token is None:
return self._token
else:
return self._token()

def get_base_url(self) -> str:
return self._base_url


class SyncClientWrapper(BaseClientWrapper):
def __init__(
self,
*,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
base_url: str,
httpx_client: httpx.Client,
):
super().__init__(token=token, base_url=base_url)
self.httpx_client = httpx_client


class AsyncClientWrapper(BaseClientWrapper):
def __init__(
self,
*,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
base_url: str,
httpx_client: httpx.AsyncClient,
):
super().__init__(token=token, base_url=base_url)
self.httpx_client = httpx_client
11 changes: 11 additions & 0 deletions src/superagent/core/remove_none_from_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was auto-generated by Fern from our API Definition.

from typing import Any, Dict, Optional


def remove_none_from_dict(original: Dict[str, Optional[Any]]) -> Dict[str, Any]:
new: Dict[str, Any] = {}
for key, value in original.items():
if value is not None:
new[key] = value
return new
11 changes: 0 additions & 11 deletions src/superagent/core/remove_none_from_headers.py

This file was deleted.

Loading

0 comments on commit 13d63d8

Please sign in to comment.