Skip to content

Commit 75bdc3f

Browse files
authored
Merge pull request #147 from Aleph-Alpha/add-ssl-bool
Add ssl bool
2 parents eda4801 + d62ca88 commit 75bdc3f

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

.github/workflows/integration.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
# We support latest 3.x version and 3.7 because
11-
# Google Colab uses 3.7 by default.
12-
python-version: [3.7, 3.x]
10+
# We currently only support up to python 3.11
11+
# because aiohttp does not support 3.12 as of yet.
12+
# 3.7 because Google Colab uses 3.7 by default.
13+
python-version: [3.7, 3.11]
1314

1415
steps:
1516
- uses: actions/checkout@v3

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.1.0
4+
5+
- Added `verify_ssl` flag so you can disable SSL checking for your sessions.
6+
37
## 4.0.0
48

59
- Turned all NamedTuples into Dataclasses. Even if this is technically a breaking change

aleph_alpha_client/aleph_alpha_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ class Client:
130130
Setting this to True, will signal to the API that you intend to be nice to other users
131131
by de-prioritizing your request below concurrent ones.
132132
133+
verify_ssl(bool, optional, default True)
134+
Setting this to False will disable checking for SSL when doing requests.
135+
133136
Example usage:
134137
>>> request = CompletionRequest(
135138
prompt=Prompt.from_text(f"Request"), maximum_tokens=64
@@ -146,6 +149,7 @@ def __init__(
146149
request_timeout_seconds: int = DEFAULT_REQUEST_TIMEOUT,
147150
total_retries: int = 8,
148151
nice: bool = False,
152+
verify_ssl = True,
149153
) -> None:
150154
if host[-1] != "/":
151155
host += "/"
@@ -164,6 +168,7 @@ def __init__(
164168
)
165169
adapter = HTTPAdapter(max_retries=retry_strategy)
166170
self.session = requests.Session()
171+
self.session.verify = verify_ssl
167172
self.session.headers = CaseInsensitiveDict(
168173
{
169174
"Authorization": "Bearer " + self.token,
@@ -603,6 +608,9 @@ class AsyncClient:
603608
Setting this to True, will signal to the API that you intend to be nice to other users
604609
by de-prioritizing your request below concurrent ones.
605610
611+
verify_ssl(bool, optional, default True)
612+
Setting this to False will disable checking for SSL when doing requests.
613+
606614
Example usage:
607615
>>> request = CompletionRequest(prompt=Prompt.from_text(f"Request"), maximum_tokens=64)
608616
>>> async with AsyncClient(token=os.environ["AA_TOKEN"]) as client:
@@ -617,6 +625,7 @@ def __init__(
617625
request_timeout_seconds: int = DEFAULT_REQUEST_TIMEOUT,
618626
total_retries: int = 8,
619627
nice: bool = False,
628+
verify_ssl = True,
620629
) -> None:
621630
if host[-1] != "/":
622631
host += "/"
@@ -632,6 +641,7 @@ def __init__(
632641
start_timeout=0.25,
633642
statuses=set(RETRY_STATUS_CODES),
634643
)
644+
connector = aiohttp.TCPConnector(verify_ssl=verify_ssl)
635645
self.session = RetryClient(
636646
trust_env=True, # same behaviour as requests/(Sync)Client wrt. http_proxy
637647
raise_for_status=False,
@@ -642,6 +652,7 @@ def __init__(
642652
"User-Agent": "Aleph-Alpha-Python-Client-"
643653
+ aleph_alpha_client.__version__,
644654
},
655+
connector=connector
645656
)
646657

647658
async def close(self):

aleph_alpha_client/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.0.0"
1+
__version__ = "4.1.0"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def version():
4444
install_requires=[
4545
"requests >= 2.28",
4646
"urllib3 >= 1.26",
47-
"aiohttp >= 3.8.3",
47+
"aiohttp >= 3.8.6",
4848
"aiodns >= 3.0.0",
4949
"aiohttp-retry >= 2.8.3",
5050
"tokenizers >= 0.13.2",

0 commit comments

Comments
 (0)