Skip to content

Commit

Permalink
Release v0.2.40
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 23, 2024
1 parent 72e18a8 commit 20f33f0
Show file tree
Hide file tree
Showing 73 changed files with 4,696 additions and 1,901 deletions.
109 changes: 76 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 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.2.39"
version = "v0.2.40"
description = ""
readme = "README.md"
authors = []
Expand All @@ -15,8 +15,18 @@ pydantic = ">= 1.9.2"
typing_extensions = ">= 4.0.0"

[tool.poetry.dev-dependencies]
mypy = "^1.8.0"
mypy = "1.9.0"
pytest = "^7.4.0"
pytest-asyncio = "^0.23.5"
python-dateutil = "^2.9.0"

[tool.pytest.ini_options]
testpaths = [ "tests" ]
asyncio_mode = "auto"

[tool.mypy]
plugins = ["pydantic.mypy"]


[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 2 additions & 0 deletions src/superagent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
from .errors import UnprocessableEntityError
from .resources import agent, api_key, api_user, datasource, llm, tool, vector_database, workflow, workflow_config
from .environment import SuperagentEnvironment
from .version import __version__

__all__ = [
"AgentDatasosurceList",
Expand Down Expand Up @@ -135,6 +136,7 @@
"WorkflowConfig",
"WorkflowList",
"WorkflowStepList",
"__version__",
"agent",
"api_key",
"api_user",
Expand Down
80 changes: 60 additions & 20 deletions src/superagent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,32 @@ class Superagent:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
Parameters:
- base_url: typing.Optional[str]. The base url to use for requests from the client.
Parameters
----------
base_url : typing.Optional[str]
The base url to use for requests from the client.
- environment: SuperagentEnvironment. The environment to use for requests from the client. from .environment import SuperagentEnvironment
environment : SuperagentEnvironment
The environment to use for requests from the client. from .environment import SuperagentEnvironment
Defaults to SuperagentEnvironment.DEFAULT
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
Defaults to SuperagentEnvironment.DEFAULT
- httpx_client: typing.Optional[httpx.Client]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
---
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
follow_redirects : typing.Optional[bool]
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
httpx_client : typing.Optional[httpx.Client]
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
Examples
--------
from superagent.client import Superagent
client = Superagent(
Expand All @@ -47,13 +60,20 @@ def __init__(
base_url: typing.Optional[str] = None,
environment: SuperagentEnvironment = SuperagentEnvironment.DEFAULT,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
timeout: typing.Optional[float] = 60,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.Client] = None
):
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
self._client_wrapper = SyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
token=token,
httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client,
httpx_client=httpx_client
if httpx_client is not None
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
if follow_redirects is not None
else httpx.Client(timeout=_defaulted_timeout),
timeout=_defaulted_timeout,
)
self.agent = AgentClient(client_wrapper=self._client_wrapper)
self.llm = LlmClient(client_wrapper=self._client_wrapper)
Expand All @@ -70,19 +90,32 @@ class AsyncSuperagent:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
Parameters:
- base_url: typing.Optional[str]. The base url to use for requests from the client.
Parameters
----------
base_url : typing.Optional[str]
The base url to use for requests from the client.
environment : SuperagentEnvironment
The environment to use for requests from the client. from .environment import SuperagentEnvironment
Defaults to SuperagentEnvironment.DEFAULT
- environment: SuperagentEnvironment. The environment to use for requests from the client. from .environment import SuperagentEnvironment
Defaults to SuperagentEnvironment.DEFAULT
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
timeout : typing.Optional[float]
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
follow_redirects : typing.Optional[bool]
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
httpx_client : typing.Optional[httpx.AsyncClient]
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
- httpx_client: typing.Optional[httpx.AsyncClient]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
---
Examples
--------
from superagent.client import AsyncSuperagent
client = AsyncSuperagent(
Expand All @@ -96,13 +129,20 @@ def __init__(
base_url: typing.Optional[str] = None,
environment: SuperagentEnvironment = SuperagentEnvironment.DEFAULT,
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
timeout: typing.Optional[float] = 60,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
httpx_client: typing.Optional[httpx.AsyncClient] = None
):
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
self._client_wrapper = AsyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
token=token,
httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client,
httpx_client=httpx_client
if httpx_client is not None
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
if follow_redirects is not None
else httpx.AsyncClient(timeout=_defaulted_timeout),
timeout=_defaulted_timeout,
)
self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
self.llm = AsyncLlmClient(client_wrapper=self._client_wrapper)
Expand Down
5 changes: 5 additions & 0 deletions src/superagent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from .file import File, convert_file_dict_to_httpx_tuples
from .http_client import AsyncHttpClient, HttpClient
from .jsonable_encoder import jsonable_encoder
from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from .query_encoder import encode_query
from .remove_none_from_dict import remove_none_from_dict
from .request_options import RequestOptions

Expand All @@ -19,7 +21,10 @@
"RequestOptions",
"SyncClientWrapper",
"convert_file_dict_to_httpx_tuples",
"deep_union_pydantic_dicts",
"encode_query",
"jsonable_encoder",
"pydantic_v1",
"remove_none_from_dict",
"serialize_datetime",
]
Loading

0 comments on commit 20f33f0

Please sign in to comment.