perplexityai 0.10.0__tar.gz → 0.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of perplexityai might be problematic. Click here for more details.
- perplexityai-0.12.0/.release-please-manifest.json +3 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/CHANGELOG.md +41 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/CONTRIBUTING.md +2 -2
- {perplexityai-0.10.0 → perplexityai-0.12.0}/PKG-INFO +10 -10
- {perplexityai-0.10.0 → perplexityai-0.12.0}/README.md +3 -3
- {perplexityai-0.10.0 → perplexityai-0.12.0}/pyproject.toml +4 -4
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/__init__.py +3 -1
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_base_client.py +9 -9
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_client.py +8 -8
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_qs.py +7 -7
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_types.py +18 -11
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_transform.py +2 -2
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_utils.py +4 -4
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_version.py +1 -1
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/async_/async_.py +4 -4
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/async_/chat/chat.py +4 -4
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/async_/chat/completions.py +25 -25
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/chat/chat.py +4 -4
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/chat/completions.py +111 -111
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/search.py +19 -15
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/search_create_params.py +2 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/test_search.py +2 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_transform.py +9 -2
- perplexityai-0.10.0/.release-please-manifest.json +0 -3
- {perplexityai-0.10.0 → perplexityai-0.12.0}/.gitignore +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/LICENSE +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/SECURITY.md +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/api.md +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/bin/check-release-environment +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/bin/publish-pypi +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/examples/.keep +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/noxfile.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/release-please-config.json +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/requirements-dev.lock +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/requirements.lock +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_compat.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_constants.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_exceptions.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_files.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_models.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_resource.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_streaming.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_compat.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_datetime_parse.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_logs.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_proxy.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_reflection.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_resources_proxy.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_streams.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_sync.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/_utils/_typing.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/lib/.keep +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/py.typed +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/async_/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/async_/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/resources/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/completion_create_params.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/completion_create_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/completion_get_params.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/completion_get_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/async_/chat/completion_list_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/chat/completion_create_params.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/chat/completion_create_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/search_create_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/api_public_search_result.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/chat_message_input.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/chat_message_output.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/choice.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared/usage_info.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared_params/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared_params/api_public_search_result.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/src/perplexity/types/shared_params/chat_message_input.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/async_/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/async_/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/async_/chat/test_completions.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/chat/__init__.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/api_resources/chat/test_completions.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/conftest.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/sample_file.txt +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_client.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_deepcopy.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_extract_files.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_files.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_models.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_qs.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_required_args.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_response.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_streaming.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_utils/test_proxy.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/test_utils/test_typing.py +0 -0
- {perplexityai-0.10.0 → perplexityai-0.12.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.0 (2025-09-26)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.11.0...v0.12.0](https://github.com/perplexityai/perplexity-py/compare/v0.11.0...v0.12.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** add /chat/completions and /async/chat/completions ([945f7c2](https://github.com/perplexityai/perplexity-py/commit/945f7c27c80ca90f6c703590578a414351e0adb2))
|
|
10
|
+
* **api:** add /content endpoint ([7c08ab9](https://github.com/perplexityai/perplexity-py/commit/7c08ab9a1a728ddf8da3523b330e28c8f3f40cd4))
|
|
11
|
+
* **api:** change bearer_token to api_key ([af29515](https://github.com/perplexityai/perplexity-py/commit/af295151b4ff3dc44dc5768aa0e965a8f5984840))
|
|
12
|
+
* **api:** include /content endpoint ([46697bc](https://github.com/perplexityai/perplexity-py/commit/46697bc483a4647c47368820badcdea6753a1078))
|
|
13
|
+
* **api:** manual updates ([d0b1071](https://github.com/perplexityai/perplexity-py/commit/d0b1071f0a16cf589c8c7d58dd545f8455eb6878))
|
|
14
|
+
* **api:** manual updates ([7f38b2f](https://github.com/perplexityai/perplexity-py/commit/7f38b2f1eb750a6d5e435a5bfd376b62fa5a9594))
|
|
15
|
+
* **api:** manual updates ([8fbe318](https://github.com/perplexityai/perplexity-py/commit/8fbe318c5ed7df04335c2cd14de708cae5780623))
|
|
16
|
+
* **api:** update from perform -> create ([c88982f](https://github.com/perplexityai/perplexity-py/commit/c88982f6b0b3ae6060f0754e1cbb8aa3035e4054))
|
|
17
|
+
* **api:** update via SDK Studio ([5a26918](https://github.com/perplexityai/perplexity-py/commit/5a269186a185f62a94fbfc57e627f8820194dc23))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Chores
|
|
21
|
+
|
|
22
|
+
* do not install brew dependencies in ./scripts/bootstrap by default ([6642343](https://github.com/perplexityai/perplexity-py/commit/66423439ddc11f2db05dc47f71b362c37681a557))
|
|
23
|
+
* **internal:** update pydantic dependency ([cac84f2](https://github.com/perplexityai/perplexity-py/commit/cac84f25cd550ee57f8971d74231f63ba8d36905))
|
|
24
|
+
* remove custom code ([3270d55](https://github.com/perplexityai/perplexity-py/commit/3270d55b91143e4b9dbc118f39791d36444e0409))
|
|
25
|
+
* **types:** change optional parameter type from NotGiven to Omit ([3b0edc9](https://github.com/perplexityai/perplexity-py/commit/3b0edc968f37f3a4233d0a66333e526a23f5073e))
|
|
26
|
+
* update SDK settings ([bcb8f64](https://github.com/perplexityai/perplexity-py/commit/bcb8f64648137caf170f0cf4b9816a39780c9f9c))
|
|
27
|
+
* update SDK settings ([99e08d9](https://github.com/perplexityai/perplexity-py/commit/99e08d9fb37306acce60d1da281c98d082d34995))
|
|
28
|
+
* update SDK settings ([6de8ec2](https://github.com/perplexityai/perplexity-py/commit/6de8ec2ca199470e9f7b70a4f840a6aeef3b1104))
|
|
29
|
+
|
|
30
|
+
## 0.11.0 (2025-09-24)
|
|
31
|
+
|
|
32
|
+
Full Changelog: [v0.10.0...v0.11.0](https://github.com/ppl-ai/perplexity-py/compare/v0.10.0...v0.11.0)
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **api:** manual updates ([d0b1071](https://github.com/ppl-ai/perplexity-py/commit/d0b1071f0a16cf589c8c7d58dd545f8455eb6878))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Chores
|
|
40
|
+
|
|
41
|
+
* do not install brew dependencies in ./scripts/bootstrap by default ([6642343](https://github.com/ppl-ai/perplexity-py/commit/66423439ddc11f2db05dc47f71b362c37681a557))
|
|
42
|
+
* **types:** change optional parameter type from NotGiven to Omit ([3b0edc9](https://github.com/ppl-ai/perplexity-py/commit/3b0edc968f37f3a4233d0a66333e526a23f5073e))
|
|
43
|
+
|
|
3
44
|
## 0.10.0 (2025-09-19)
|
|
4
45
|
|
|
5
46
|
Full Changelog: [v0.9.0...v0.10.0](https://github.com/ppl-ai/perplexity-py/compare/v0.9.0...v0.10.0)
|
|
@@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
|
|
|
62
62
|
To install via git:
|
|
63
63
|
|
|
64
64
|
```sh
|
|
65
|
-
$ pip install git+ssh://git@github.com/
|
|
65
|
+
$ pip install git+ssh://git@github.com/perplexityai/perplexity-py.git
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Alternatively, you can build from source and install the wheel file:
|
|
@@ -120,7 +120,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
|
|
|
120
120
|
|
|
121
121
|
### Publish with a GitHub workflow
|
|
122
122
|
|
|
123
|
-
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/
|
|
123
|
+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/perplexityai/perplexity-py/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
|
|
124
124
|
|
|
125
125
|
### Publish manually
|
|
126
126
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: perplexityai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0
|
|
4
4
|
Summary: The official Python library for the perplexity API
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL: Repository, https://github.com/
|
|
5
|
+
Project-URL: Homepage, https://github.com/perplexityai/perplexity-py
|
|
6
|
+
Project-URL: Repository, https://github.com/perplexityai/perplexity-py
|
|
7
7
|
Author: Perplexity
|
|
8
8
|
License: Apache-2.0
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
@@ -46,7 +46,7 @@ It is generated with [Stainless](https://www.stainless.com/).
|
|
|
46
46
|
|
|
47
47
|
## Documentation
|
|
48
48
|
|
|
49
|
-
The full API of this library can be found in [api.md](https://github.com/
|
|
49
|
+
The full API of this library can be found in [api.md](https://github.com/perplexityai/perplexity-py/tree/main/api.md).
|
|
50
50
|
|
|
51
51
|
## Installation
|
|
52
52
|
|
|
@@ -96,7 +96,7 @@ for result in content.results:
|
|
|
96
96
|
|
|
97
97
|
## Chat Completions
|
|
98
98
|
|
|
99
|
-
The full API of this library can be found in [api.md](https://github.com/
|
|
99
|
+
The full API of this library can be found in [api.md](https://github.com/perplexityai/perplexity-py/tree/main/api.md).
|
|
100
100
|
|
|
101
101
|
```python
|
|
102
102
|
import os
|
|
@@ -336,7 +336,7 @@ client.with_options(timeout=5.0).chat.completions.create(
|
|
|
336
336
|
|
|
337
337
|
On timeout, an `APITimeoutError` is thrown.
|
|
338
338
|
|
|
339
|
-
Note that requests that time out are [retried twice by default](https://github.com/
|
|
339
|
+
Note that requests that time out are [retried twice by default](https://github.com/perplexityai/perplexity-py/tree/main/#retries).
|
|
340
340
|
|
|
341
341
|
## Advanced
|
|
342
342
|
|
|
@@ -385,9 +385,9 @@ completion = response.parse() # get the object that `chat.completions.create()`
|
|
|
385
385
|
print(completion.id)
|
|
386
386
|
```
|
|
387
387
|
|
|
388
|
-
These methods return an [`APIResponse`](https://github.com/
|
|
388
|
+
These methods return an [`APIResponse`](https://github.com/perplexityai/perplexity-py/tree/main/src/perplexity/_response.py) object.
|
|
389
389
|
|
|
390
|
-
The async client returns an [`AsyncAPIResponse`](https://github.com/
|
|
390
|
+
The async client returns an [`AsyncAPIResponse`](https://github.com/perplexityai/perplexity-py/tree/main/src/perplexity/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
|
|
391
391
|
|
|
392
392
|
#### `.with_streaming_response`
|
|
393
393
|
|
|
@@ -499,7 +499,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
499
499
|
|
|
500
500
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
501
501
|
|
|
502
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/
|
|
502
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/perplexityai/perplexity-py/issues) with questions, bugs, or suggestions.
|
|
503
503
|
|
|
504
504
|
### Determining the installed version
|
|
505
505
|
|
|
@@ -518,4 +518,4 @@ Python 3.8 or higher.
|
|
|
518
518
|
|
|
519
519
|
## Contributing
|
|
520
520
|
|
|
521
|
-
See [the contributing documentation](https://github.com/
|
|
521
|
+
See [the contributing documentation](https://github.com/perplexityai/perplexity-py/tree/main/./CONTRIBUTING.md).
|
|
@@ -350,9 +350,9 @@ completion = response.parse() # get the object that `chat.completions.create()`
|
|
|
350
350
|
print(completion.id)
|
|
351
351
|
```
|
|
352
352
|
|
|
353
|
-
These methods return an [`APIResponse`](https://github.com/
|
|
353
|
+
These methods return an [`APIResponse`](https://github.com/perplexityai/perplexity-py/tree/main/src/perplexity/_response.py) object.
|
|
354
354
|
|
|
355
|
-
The async client returns an [`AsyncAPIResponse`](https://github.com/
|
|
355
|
+
The async client returns an [`AsyncAPIResponse`](https://github.com/perplexityai/perplexity-py/tree/main/src/perplexity/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
|
|
356
356
|
|
|
357
357
|
#### `.with_streaming_response`
|
|
358
358
|
|
|
@@ -464,7 +464,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
464
464
|
|
|
465
465
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
466
466
|
|
|
467
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/
|
|
467
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/perplexityai/perplexity-py/issues) with questions, bugs, or suggestions.
|
|
468
468
|
|
|
469
469
|
### Determining the installed version
|
|
470
470
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "perplexityai"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.12.0"
|
|
4
4
|
description = "The official Python library for the perplexity API"
|
|
5
5
|
dynamic = ["readme"]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -35,8 +35,8 @@ classifiers = [
|
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
[project.urls]
|
|
38
|
-
Homepage = "https://github.com/
|
|
39
|
-
Repository = "https://github.com/
|
|
38
|
+
Homepage = "https://github.com/perplexityai/perplexity-py"
|
|
39
|
+
Repository = "https://github.com/perplexityai/perplexity-py"
|
|
40
40
|
|
|
41
41
|
[project.optional-dependencies]
|
|
42
42
|
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]
|
|
@@ -124,7 +124,7 @@ path = "README.md"
|
|
|
124
124
|
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
|
|
125
125
|
# replace relative links with absolute links
|
|
126
126
|
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
|
|
127
|
-
replacement = '[\1](https://github.com/
|
|
127
|
+
replacement = '[\1](https://github.com/perplexityai/perplexity-py/tree/main/\g<2>)'
|
|
128
128
|
|
|
129
129
|
[tool.pytest.ini_options]
|
|
130
130
|
testpaths = ["tests"]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import typing as _t
|
|
4
4
|
|
|
5
5
|
from . import types
|
|
6
|
-
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
|
|
6
|
+
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
|
|
7
7
|
from ._utils import file_from_path
|
|
8
8
|
from ._client import (
|
|
9
9
|
Client,
|
|
@@ -48,7 +48,9 @@ __all__ = [
|
|
|
48
48
|
"ProxiesTypes",
|
|
49
49
|
"NotGiven",
|
|
50
50
|
"NOT_GIVEN",
|
|
51
|
+
"not_given",
|
|
51
52
|
"Omit",
|
|
53
|
+
"omit",
|
|
52
54
|
"PerplexityError",
|
|
53
55
|
"APIError",
|
|
54
56
|
"APIStatusError",
|
|
@@ -42,7 +42,6 @@ from . import _exceptions
|
|
|
42
42
|
from ._qs import Querystring
|
|
43
43
|
from ._files import to_httpx_files, async_to_httpx_files
|
|
44
44
|
from ._types import (
|
|
45
|
-
NOT_GIVEN,
|
|
46
45
|
Body,
|
|
47
46
|
Omit,
|
|
48
47
|
Query,
|
|
@@ -57,6 +56,7 @@ from ._types import (
|
|
|
57
56
|
RequestOptions,
|
|
58
57
|
HttpxRequestFiles,
|
|
59
58
|
ModelBuilderProtocol,
|
|
59
|
+
not_given,
|
|
60
60
|
)
|
|
61
61
|
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
|
|
62
62
|
from ._compat import PYDANTIC_V1, model_copy, model_dump
|
|
@@ -145,9 +145,9 @@ class PageInfo:
|
|
|
145
145
|
def __init__(
|
|
146
146
|
self,
|
|
147
147
|
*,
|
|
148
|
-
url: URL | NotGiven =
|
|
149
|
-
json: Body | NotGiven =
|
|
150
|
-
params: Query | NotGiven =
|
|
148
|
+
url: URL | NotGiven = not_given,
|
|
149
|
+
json: Body | NotGiven = not_given,
|
|
150
|
+
params: Query | NotGiven = not_given,
|
|
151
151
|
) -> None:
|
|
152
152
|
self.url = url
|
|
153
153
|
self.json = json
|
|
@@ -595,7 +595,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
595
595
|
# we internally support defining a temporary header to override the
|
|
596
596
|
# default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
|
|
597
597
|
# see _response.py for implementation details
|
|
598
|
-
override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER,
|
|
598
|
+
override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
|
|
599
599
|
if is_given(override_cast_to):
|
|
600
600
|
options.headers = headers
|
|
601
601
|
return cast(Type[ResponseT], override_cast_to)
|
|
@@ -825,7 +825,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
825
825
|
version: str,
|
|
826
826
|
base_url: str | URL,
|
|
827
827
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
828
|
-
timeout: float | Timeout | None | NotGiven =
|
|
828
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
829
829
|
http_client: httpx.Client | None = None,
|
|
830
830
|
custom_headers: Mapping[str, str] | None = None,
|
|
831
831
|
custom_query: Mapping[str, object] | None = None,
|
|
@@ -1356,7 +1356,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1356
1356
|
base_url: str | URL,
|
|
1357
1357
|
_strict_response_validation: bool,
|
|
1358
1358
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
1359
|
-
timeout: float | Timeout | None | NotGiven =
|
|
1359
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
1360
1360
|
http_client: httpx.AsyncClient | None = None,
|
|
1361
1361
|
custom_headers: Mapping[str, str] | None = None,
|
|
1362
1362
|
custom_query: Mapping[str, object] | None = None,
|
|
@@ -1818,8 +1818,8 @@ def make_request_options(
|
|
|
1818
1818
|
extra_query: Query | None = None,
|
|
1819
1819
|
extra_body: Body | None = None,
|
|
1820
1820
|
idempotency_key: str | None = None,
|
|
1821
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
1822
|
-
post_parser: PostParser | NotGiven =
|
|
1821
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1822
|
+
post_parser: PostParser | NotGiven = not_given,
|
|
1823
1823
|
) -> RequestOptions:
|
|
1824
1824
|
"""Create a dict of type RequestOptions without keys of NotGiven values."""
|
|
1825
1825
|
options: RequestOptions = {}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Mapping
|
|
7
7
|
from typing_extensions import Self, override
|
|
8
8
|
|
|
9
9
|
import httpx
|
|
@@ -11,13 +11,13 @@ import httpx
|
|
|
11
11
|
from . import _exceptions
|
|
12
12
|
from ._qs import Querystring
|
|
13
13
|
from ._types import (
|
|
14
|
-
NOT_GIVEN,
|
|
15
14
|
Omit,
|
|
16
15
|
Timeout,
|
|
17
16
|
NotGiven,
|
|
18
17
|
Transport,
|
|
19
18
|
ProxiesTypes,
|
|
20
19
|
RequestOptions,
|
|
20
|
+
not_given,
|
|
21
21
|
)
|
|
22
22
|
from ._utils import is_given, get_async_library
|
|
23
23
|
from ._version import __version__
|
|
@@ -59,7 +59,7 @@ class Perplexity(SyncAPIClient):
|
|
|
59
59
|
*,
|
|
60
60
|
api_key: str | None = None,
|
|
61
61
|
base_url: str | httpx.URL | None = None,
|
|
62
|
-
timeout:
|
|
62
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
63
63
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
64
64
|
default_headers: Mapping[str, str] | None = None,
|
|
65
65
|
default_query: Mapping[str, object] | None = None,
|
|
@@ -136,9 +136,9 @@ class Perplexity(SyncAPIClient):
|
|
|
136
136
|
*,
|
|
137
137
|
api_key: str | None = None,
|
|
138
138
|
base_url: str | httpx.URL | None = None,
|
|
139
|
-
timeout: float | Timeout | None | NotGiven =
|
|
139
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
140
140
|
http_client: httpx.Client | None = None,
|
|
141
|
-
max_retries: int | NotGiven =
|
|
141
|
+
max_retries: int | NotGiven = not_given,
|
|
142
142
|
default_headers: Mapping[str, str] | None = None,
|
|
143
143
|
set_default_headers: Mapping[str, str] | None = None,
|
|
144
144
|
default_query: Mapping[str, object] | None = None,
|
|
@@ -231,7 +231,7 @@ class AsyncPerplexity(AsyncAPIClient):
|
|
|
231
231
|
*,
|
|
232
232
|
api_key: str | None = None,
|
|
233
233
|
base_url: str | httpx.URL | None = None,
|
|
234
|
-
timeout:
|
|
234
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
235
235
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
236
236
|
default_headers: Mapping[str, str] | None = None,
|
|
237
237
|
default_query: Mapping[str, object] | None = None,
|
|
@@ -308,9 +308,9 @@ class AsyncPerplexity(AsyncAPIClient):
|
|
|
308
308
|
*,
|
|
309
309
|
api_key: str | None = None,
|
|
310
310
|
base_url: str | httpx.URL | None = None,
|
|
311
|
-
timeout: float | Timeout | None | NotGiven =
|
|
311
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
312
312
|
http_client: httpx.AsyncClient | None = None,
|
|
313
|
-
max_retries: int | NotGiven =
|
|
313
|
+
max_retries: int | NotGiven = not_given,
|
|
314
314
|
default_headers: Mapping[str, str] | None = None,
|
|
315
315
|
set_default_headers: Mapping[str, str] | None = None,
|
|
316
316
|
default_query: Mapping[str, object] | None = None,
|
|
@@ -4,7 +4,7 @@ from typing import Any, List, Tuple, Union, Mapping, TypeVar
|
|
|
4
4
|
from urllib.parse import parse_qs, urlencode
|
|
5
5
|
from typing_extensions import Literal, get_args
|
|
6
6
|
|
|
7
|
-
from ._types import
|
|
7
|
+
from ._types import NotGiven, not_given
|
|
8
8
|
from ._utils import flatten
|
|
9
9
|
|
|
10
10
|
_T = TypeVar("_T")
|
|
@@ -41,8 +41,8 @@ class Querystring:
|
|
|
41
41
|
self,
|
|
42
42
|
params: Params,
|
|
43
43
|
*,
|
|
44
|
-
array_format:
|
|
45
|
-
nested_format:
|
|
44
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
45
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
46
46
|
) -> str:
|
|
47
47
|
return urlencode(
|
|
48
48
|
self.stringify_items(
|
|
@@ -56,8 +56,8 @@ class Querystring:
|
|
|
56
56
|
self,
|
|
57
57
|
params: Params,
|
|
58
58
|
*,
|
|
59
|
-
array_format:
|
|
60
|
-
nested_format:
|
|
59
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
60
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
61
61
|
) -> list[tuple[str, str]]:
|
|
62
62
|
opts = Options(
|
|
63
63
|
qs=self,
|
|
@@ -143,8 +143,8 @@ class Options:
|
|
|
143
143
|
self,
|
|
144
144
|
qs: Querystring = _qs,
|
|
145
145
|
*,
|
|
146
|
-
array_format:
|
|
147
|
-
nested_format:
|
|
146
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
147
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
148
148
|
) -> None:
|
|
149
149
|
self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
|
|
150
150
|
self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
|
|
@@ -117,18 +117,21 @@ class RequestOptions(TypedDict, total=False):
|
|
|
117
117
|
# Sentinel class used until PEP 0661 is accepted
|
|
118
118
|
class NotGiven:
|
|
119
119
|
"""
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
For parameters with a meaningful None value, we need to distinguish between
|
|
121
|
+
the user explicitly passing None, and the user not passing the parameter at
|
|
122
|
+
all.
|
|
123
|
+
|
|
124
|
+
User code shouldn't need to use not_given directly.
|
|
122
125
|
|
|
123
126
|
For example:
|
|
124
127
|
|
|
125
128
|
```py
|
|
126
|
-
def
|
|
129
|
+
def create(timeout: Timeout | None | NotGiven = not_given): ...
|
|
127
130
|
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
create(timeout=1) # 1s timeout
|
|
133
|
+
create(timeout=None) # No timeout
|
|
134
|
+
create() # Default timeout behavior
|
|
132
135
|
```
|
|
133
136
|
"""
|
|
134
137
|
|
|
@@ -140,13 +143,14 @@ class NotGiven:
|
|
|
140
143
|
return "NOT_GIVEN"
|
|
141
144
|
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
not_given = NotGiven()
|
|
147
|
+
# for backwards compatibility:
|
|
144
148
|
NOT_GIVEN = NotGiven()
|
|
145
149
|
|
|
146
150
|
|
|
147
151
|
class Omit:
|
|
148
|
-
"""
|
|
149
|
-
|
|
152
|
+
"""
|
|
153
|
+
To explicitly omit something from being sent in a request, use `omit`.
|
|
150
154
|
|
|
151
155
|
```py
|
|
152
156
|
# as the default `Content-Type` header is `application/json` that will be sent
|
|
@@ -156,8 +160,8 @@ class Omit:
|
|
|
156
160
|
# to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983'
|
|
157
161
|
client.post(..., headers={"Content-Type": "multipart/form-data"})
|
|
158
162
|
|
|
159
|
-
# instead you can remove the default `application/json` header by passing
|
|
160
|
-
client.post(..., headers={"Content-Type":
|
|
163
|
+
# instead you can remove the default `application/json` header by passing omit
|
|
164
|
+
client.post(..., headers={"Content-Type": omit})
|
|
161
165
|
```
|
|
162
166
|
"""
|
|
163
167
|
|
|
@@ -165,6 +169,9 @@ class Omit:
|
|
|
165
169
|
return False
|
|
166
170
|
|
|
167
171
|
|
|
172
|
+
omit = Omit()
|
|
173
|
+
|
|
174
|
+
|
|
168
175
|
@runtime_checkable
|
|
169
176
|
class ModelBuilderProtocol(Protocol):
|
|
170
177
|
@classmethod
|
|
@@ -268,7 +268,7 @@ def _transform_typeddict(
|
|
|
268
268
|
annotations = get_type_hints(expected_type, include_extras=True)
|
|
269
269
|
for key, value in data.items():
|
|
270
270
|
if not is_given(value):
|
|
271
|
-
# we don't need to include
|
|
271
|
+
# we don't need to include omitted values here as they'll
|
|
272
272
|
# be stripped out before the request is sent anyway
|
|
273
273
|
continue
|
|
274
274
|
|
|
@@ -434,7 +434,7 @@ async def _async_transform_typeddict(
|
|
|
434
434
|
annotations = get_type_hints(expected_type, include_extras=True)
|
|
435
435
|
for key, value in data.items():
|
|
436
436
|
if not is_given(value):
|
|
437
|
-
# we don't need to include
|
|
437
|
+
# we don't need to include omitted values here as they'll
|
|
438
438
|
# be stripped out before the request is sent anyway
|
|
439
439
|
continue
|
|
440
440
|
|
|
@@ -21,7 +21,7 @@ from typing_extensions import TypeGuard
|
|
|
21
21
|
|
|
22
22
|
import sniffio
|
|
23
23
|
|
|
24
|
-
from .._types import NotGiven, FileTypes,
|
|
24
|
+
from .._types import Omit, NotGiven, FileTypes, HeadersLike
|
|
25
25
|
|
|
26
26
|
_T = TypeVar("_T")
|
|
27
27
|
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
|
|
@@ -63,7 +63,7 @@ def _extract_items(
|
|
|
63
63
|
try:
|
|
64
64
|
key = path[index]
|
|
65
65
|
except IndexError:
|
|
66
|
-
if
|
|
66
|
+
if not is_given(obj):
|
|
67
67
|
# no value was provided - we can safely ignore
|
|
68
68
|
return []
|
|
69
69
|
|
|
@@ -126,8 +126,8 @@ def _extract_items(
|
|
|
126
126
|
return []
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
def is_given(obj:
|
|
130
|
-
return not isinstance(obj, NotGiven)
|
|
129
|
+
def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
|
|
130
|
+
return not isinstance(obj, NotGiven) and not isinstance(obj, Omit)
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
# Type safe methods for narrowing types with TypeVars.
|
|
@@ -27,7 +27,7 @@ class AsyncResource(SyncAPIResource):
|
|
|
27
27
|
This property can be used as a prefix for any HTTP method call to return
|
|
28
28
|
the raw response object instead of the parsed content.
|
|
29
29
|
|
|
30
|
-
For more information, see https://www.github.com/
|
|
30
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
31
31
|
"""
|
|
32
32
|
return AsyncResourceWithRawResponse(self)
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ class AsyncResource(SyncAPIResource):
|
|
|
36
36
|
"""
|
|
37
37
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
38
38
|
|
|
39
|
-
For more information, see https://www.github.com/
|
|
39
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
40
40
|
"""
|
|
41
41
|
return AsyncResourceWithStreamingResponse(self)
|
|
42
42
|
|
|
@@ -52,7 +52,7 @@ class AsyncAsyncResource(AsyncAPIResource):
|
|
|
52
52
|
This property can be used as a prefix for any HTTP method call to return
|
|
53
53
|
the raw response object instead of the parsed content.
|
|
54
54
|
|
|
55
|
-
For more information, see https://www.github.com/
|
|
55
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
56
56
|
"""
|
|
57
57
|
return AsyncAsyncResourceWithRawResponse(self)
|
|
58
58
|
|
|
@@ -61,7 +61,7 @@ class AsyncAsyncResource(AsyncAPIResource):
|
|
|
61
61
|
"""
|
|
62
62
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
63
63
|
|
|
64
|
-
For more information, see https://www.github.com/
|
|
64
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
65
65
|
"""
|
|
66
66
|
return AsyncAsyncResourceWithStreamingResponse(self)
|
|
67
67
|
|
|
@@ -27,7 +27,7 @@ class ChatResource(SyncAPIResource):
|
|
|
27
27
|
This property can be used as a prefix for any HTTP method call to return
|
|
28
28
|
the raw response object instead of the parsed content.
|
|
29
29
|
|
|
30
|
-
For more information, see https://www.github.com/
|
|
30
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
31
31
|
"""
|
|
32
32
|
return ChatResourceWithRawResponse(self)
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ class ChatResource(SyncAPIResource):
|
|
|
36
36
|
"""
|
|
37
37
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
38
38
|
|
|
39
|
-
For more information, see https://www.github.com/
|
|
39
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
40
40
|
"""
|
|
41
41
|
return ChatResourceWithStreamingResponse(self)
|
|
42
42
|
|
|
@@ -52,7 +52,7 @@ class AsyncChatResource(AsyncAPIResource):
|
|
|
52
52
|
This property can be used as a prefix for any HTTP method call to return
|
|
53
53
|
the raw response object instead of the parsed content.
|
|
54
54
|
|
|
55
|
-
For more information, see https://www.github.com/
|
|
55
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
56
56
|
"""
|
|
57
57
|
return AsyncChatResourceWithRawResponse(self)
|
|
58
58
|
|
|
@@ -61,7 +61,7 @@ class AsyncChatResource(AsyncAPIResource):
|
|
|
61
61
|
"""
|
|
62
62
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
63
63
|
|
|
64
|
-
For more information, see https://www.github.com/
|
|
64
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
65
65
|
"""
|
|
66
66
|
return AsyncChatResourceWithStreamingResponse(self)
|
|
67
67
|
|