Skip to content

Commit 20f33f0

Browse files
committed
Release v0.2.40
1 parent 72e18a8 commit 20f33f0

File tree

73 files changed

+4696
-1901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4696
-1901
lines changed

poetry.lock

+76-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "superagent-py"
3-
version = "v0.2.39"
3+
version = "v0.2.40"
44
description = ""
55
readme = "README.md"
66
authors = []
@@ -15,8 +15,18 @@ pydantic = ">= 1.9.2"
1515
typing_extensions = ">= 4.0.0"
1616

1717
[tool.poetry.dev-dependencies]
18-
mypy = "^1.8.0"
18+
mypy = "1.9.0"
1919
pytest = "^7.4.0"
20+
pytest-asyncio = "^0.23.5"
21+
python-dateutil = "^2.9.0"
22+
23+
[tool.pytest.ini_options]
24+
testpaths = [ "tests" ]
25+
asyncio_mode = "auto"
26+
27+
[tool.mypy]
28+
plugins = ["pydantic.mypy"]
29+
2030

2131
[build-system]
2232
requires = ["poetry-core"]

src/superagent/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from .errors import UnprocessableEntityError
6969
from .resources import agent, api_key, api_user, datasource, llm, tool, vector_database, workflow, workflow_config
7070
from .environment import SuperagentEnvironment
71+
from .version import __version__
7172

7273
__all__ = [
7374
"AgentDatasosurceList",
@@ -135,6 +136,7 @@
135136
"WorkflowConfig",
136137
"WorkflowList",
137138
"WorkflowStepList",
139+
"__version__",
138140
"agent",
139141
"api_key",
140142
"api_user",

src/superagent/client.py

+60-20
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,32 @@ class Superagent:
2121
"""
2222
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.
2323
24-
Parameters:
25-
- base_url: typing.Optional[str]. The base url to use for requests from the client.
24+
Parameters
25+
----------
26+
base_url : typing.Optional[str]
27+
The base url to use for requests from the client.
2628
27-
- environment: SuperagentEnvironment. The environment to use for requests from the client. from .environment import SuperagentEnvironment
29+
environment : SuperagentEnvironment
30+
The environment to use for requests from the client. from .environment import SuperagentEnvironment
2831
29-
Defaults to SuperagentEnvironment.DEFAULT
3032
31-
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
3233
33-
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
34+
Defaults to SuperagentEnvironment.DEFAULT
3435
35-
- 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.
36-
---
36+
37+
38+
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
39+
timeout : typing.Optional[float]
40+
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.
41+
42+
follow_redirects : typing.Optional[bool]
43+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
44+
45+
httpx_client : typing.Optional[httpx.Client]
46+
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.
47+
48+
Examples
49+
--------
3750
from superagent.client import Superagent
3851
3952
client = Superagent(
@@ -47,13 +60,20 @@ def __init__(
4760
base_url: typing.Optional[str] = None,
4861
environment: SuperagentEnvironment = SuperagentEnvironment.DEFAULT,
4962
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
50-
timeout: typing.Optional[float] = 60,
63+
timeout: typing.Optional[float] = None,
64+
follow_redirects: typing.Optional[bool] = True,
5165
httpx_client: typing.Optional[httpx.Client] = None
5266
):
67+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
5368
self._client_wrapper = SyncClientWrapper(
5469
base_url=_get_base_url(base_url=base_url, environment=environment),
5570
token=token,
56-
httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client,
71+
httpx_client=httpx_client
72+
if httpx_client is not None
73+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
74+
if follow_redirects is not None
75+
else httpx.Client(timeout=_defaulted_timeout),
76+
timeout=_defaulted_timeout,
5777
)
5878
self.agent = AgentClient(client_wrapper=self._client_wrapper)
5979
self.llm = LlmClient(client_wrapper=self._client_wrapper)
@@ -70,19 +90,32 @@ class AsyncSuperagent:
7090
"""
7191
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.
7292
73-
Parameters:
74-
- base_url: typing.Optional[str]. The base url to use for requests from the client.
93+
Parameters
94+
----------
95+
base_url : typing.Optional[str]
96+
The base url to use for requests from the client.
97+
98+
environment : SuperagentEnvironment
99+
The environment to use for requests from the client. from .environment import SuperagentEnvironment
100+
101+
102+
103+
Defaults to SuperagentEnvironment.DEFAULT
104+
75105
76-
- environment: SuperagentEnvironment. The environment to use for requests from the client. from .environment import SuperagentEnvironment
77106
78-
Defaults to SuperagentEnvironment.DEFAULT
107+
token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
108+
timeout : typing.Optional[float]
109+
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.
79110
80-
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
111+
follow_redirects : typing.Optional[bool]
112+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
81113
82-
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
114+
httpx_client : typing.Optional[httpx.AsyncClient]
115+
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.
83116
84-
- 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.
85-
---
117+
Examples
118+
--------
86119
from superagent.client import AsyncSuperagent
87120
88121
client = AsyncSuperagent(
@@ -96,13 +129,20 @@ def __init__(
96129
base_url: typing.Optional[str] = None,
97130
environment: SuperagentEnvironment = SuperagentEnvironment.DEFAULT,
98131
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
99-
timeout: typing.Optional[float] = 60,
132+
timeout: typing.Optional[float] = None,
133+
follow_redirects: typing.Optional[bool] = True,
100134
httpx_client: typing.Optional[httpx.AsyncClient] = None
101135
):
136+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
102137
self._client_wrapper = AsyncClientWrapper(
103138
base_url=_get_base_url(base_url=base_url, environment=environment),
104139
token=token,
105-
httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client,
140+
httpx_client=httpx_client
141+
if httpx_client is not None
142+
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
143+
if follow_redirects is not None
144+
else httpx.AsyncClient(timeout=_defaulted_timeout),
145+
timeout=_defaulted_timeout,
106146
)
107147
self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
108148
self.llm = AsyncLlmClient(client_wrapper=self._client_wrapper)

src/superagent/core/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from .file import File, convert_file_dict_to_httpx_tuples
77
from .http_client import AsyncHttpClient, HttpClient
88
from .jsonable_encoder import jsonable_encoder
9+
from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
10+
from .query_encoder import encode_query
911
from .remove_none_from_dict import remove_none_from_dict
1012
from .request_options import RequestOptions
1113

@@ -19,7 +21,10 @@
1921
"RequestOptions",
2022
"SyncClientWrapper",
2123
"convert_file_dict_to_httpx_tuples",
24+
"deep_union_pydantic_dicts",
25+
"encode_query",
2226
"jsonable_encoder",
27+
"pydantic_v1",
2328
"remove_none_from_dict",
2429
"serialize_datetime",
2530
]

0 commit comments

Comments
 (0)