perplexityai 0.7.1__tar.gz → 0.8.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.8.0/.release-please-manifest.json +3 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/CHANGELOG.md +12 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/PKG-INFO +44 -5
- {perplexityai-0.7.1 → perplexityai-0.8.0}/README.md +43 -4
- {perplexityai-0.7.1 → perplexityai-0.8.0}/api.md +9 -3
- {perplexityai-0.7.1 → perplexityai-0.8.0}/pyproject.toml +1 -1
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_version.py +1 -1
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/chat/completions.py +90 -76
- perplexityai-0.8.0/src/perplexity/resources/chat/completions.py +393 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/content.py +2 -6
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/search.py +2 -60
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/__init__.py +4 -3
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/async_/chat/__init__.py +1 -1
- perplexityai-0.8.0/src/perplexity/types/async_/chat/completion_create_params.py +241 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/async_/chat/completion_create_response.py +13 -13
- perplexityai-0.8.0/src/perplexity/types/async_/chat/completion_get_params.py +23 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/async_/chat/completion_get_response.py +13 -13
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/async_/chat/completion_list_response.py +1 -1
- perplexityai-0.8.0/src/perplexity/types/chat/completion_create_params.py +232 -0
- perplexityai-0.8.0/src/perplexity/types/chat/completion_create_response.py +33 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/content_create_params.py +0 -1
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/content_create_response.py +0 -6
- perplexityai-0.8.0/src/perplexity/types/search_create_params.py +38 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/search_create_response.py +0 -7
- perplexityai-0.8.0/src/perplexity/types/shared/__init__.py +7 -0
- perplexityai-0.7.1/src/perplexity/types/shared/search_result.py → perplexityai-0.8.0/src/perplexity/types/shared/api_public_search_result.py +6 -2
- perplexityai-0.8.0/src/perplexity/types/shared/chat_message_input.py +212 -0
- perplexityai-0.8.0/src/perplexity/types/shared/chat_message_output.py +212 -0
- perplexityai-0.7.1/src/perplexity/types/shared/chat_choice.py → perplexityai-0.8.0/src/perplexity/types/shared/choice.py +6 -4
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/shared/usage_info.py +19 -1
- perplexityai-0.8.0/src/perplexity/types/shared_params/__init__.py +4 -0
- perplexityai-0.8.0/src/perplexity/types/shared_params/api_public_search_result.py +20 -0
- perplexityai-0.8.0/src/perplexity/types/shared_params/chat_message_input.py +216 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/async_/chat/test_completions.py +278 -40
- perplexityai-0.8.0/tests/api_resources/chat/test_completions.py +428 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_client.py +10 -10
- perplexityai-0.7.1/.release-please-manifest.json +0 -3
- perplexityai-0.7.1/src/perplexity/resources/chat/completions.py +0 -295
- perplexityai-0.7.1/src/perplexity/types/async_/chat/completion_create_params.py +0 -94
- perplexityai-0.7.1/src/perplexity/types/async_/chat/completion_list_params.py +0 -15
- perplexityai-0.7.1/src/perplexity/types/chat/completion_create_params.py +0 -90
- perplexityai-0.7.1/src/perplexity/types/chat/completion_create_response.py +0 -30
- perplexityai-0.7.1/src/perplexity/types/search_create_params.py +0 -62
- perplexityai-0.7.1/src/perplexity/types/shared/__init__.py +0 -6
- perplexityai-0.7.1/src/perplexity/types/shared/chat_message.py +0 -31
- perplexityai-0.7.1/src/perplexity/types/shared_params/__init__.py +0 -3
- perplexityai-0.7.1/src/perplexity/types/shared_params/chat_message.py +0 -31
- perplexityai-0.7.1/tests/api_resources/chat/test_completions.py +0 -202
- {perplexityai-0.7.1 → perplexityai-0.8.0}/.gitignore +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/CONTRIBUTING.md +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/LICENSE +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/SECURITY.md +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/bin/check-release-environment +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/bin/publish-pypi +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/examples/.keep +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/noxfile.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/release-please-config.json +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/requirements-dev.lock +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/requirements.lock +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_base_client.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_client.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_compat.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_constants.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_exceptions.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_files.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_models.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_qs.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_resource.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_response.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_streaming.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_types.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_compat.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_datetime_parse.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_logs.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_proxy.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_reflection.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_resources_proxy.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_streams.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_sync.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_transform.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_typing.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/_utils/_utils.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/lib/.keep +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/py.typed +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/async_.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/chat/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/chat/chat.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/chat/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/chat/chat.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/async_/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/types/chat/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/async_/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/async_/chat/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/chat/__init__.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/test_content.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/api_resources/test_search.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/conftest.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/sample_file.txt +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_deepcopy.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_extract_files.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_files.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_models.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_qs.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_required_args.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_response.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_streaming.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_transform.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_utils/test_proxy.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/test_utils/test_typing.py +0 -0
- {perplexityai-0.7.1 → perplexityai-0.8.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0 (2025-09-15)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.7.2...v0.8.0](https://github.com/ppl-ai/perplexity-py/compare/v0.7.2...v0.8.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** update via SDK Studio ([5a26918](https://github.com/ppl-ai/perplexity-py/commit/5a269186a185f62a94fbfc57e627f8820194dc23))
|
|
10
|
+
|
|
11
|
+
## 0.7.2 (2025-09-10)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.7.1...v0.7.2](https://github.com/ppl-ai/perplexity-py/compare/v0.7.1...v0.7.2)
|
|
14
|
+
|
|
3
15
|
## 0.7.1 (2025-09-10)
|
|
4
16
|
|
|
5
17
|
Full Changelog: [v0.7.0...v0.7.1](https://github.com/ppl-ai/perplexity-py/compare/v0.7.0...v0.7.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: perplexityai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: The official Python library for the perplexity API
|
|
5
5
|
Project-URL: Homepage, https://github.com/ppl-ai/perplexity-py
|
|
6
6
|
Project-URL: Repository, https://github.com/ppl-ai/perplexity-py
|
|
@@ -55,7 +55,46 @@ The full API of this library can be found in [api.md](https://github.com/ppl-ai/
|
|
|
55
55
|
pip install perplexityai
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Search API
|
|
59
|
+
|
|
60
|
+
Get web search results:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import os
|
|
64
|
+
from perplexity import Perplexity
|
|
65
|
+
|
|
66
|
+
client = Perplexity(
|
|
67
|
+
api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
search = client.search.create(
|
|
71
|
+
query="latest AI developments 2024",
|
|
72
|
+
max_results=5
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
for result in search.results:
|
|
76
|
+
print(f"{result.title}: {result.url}")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Content API
|
|
80
|
+
|
|
81
|
+
Extract and process content from URLs:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from perplexity import Perplexity
|
|
85
|
+
|
|
86
|
+
client = Perplexity()
|
|
87
|
+
|
|
88
|
+
content = client.content.create(
|
|
89
|
+
urls=["https://en.wikipedia.org/wiki/Perplexity_AI"]
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
for result in content.results:
|
|
93
|
+
print(f"Title: {result.title}")
|
|
94
|
+
print(f"Content: {result.content[:200]}...")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Chat Completions
|
|
59
98
|
|
|
60
99
|
The full API of this library can be found in [api.md](https://github.com/ppl-ai/perplexity-py/tree/main/api.md).
|
|
61
100
|
|
|
@@ -180,10 +219,10 @@ completion = client.chat.completions.create(
|
|
|
180
219
|
"role": "system",
|
|
181
220
|
}
|
|
182
221
|
],
|
|
183
|
-
model="
|
|
184
|
-
|
|
222
|
+
model="model",
|
|
223
|
+
debug_params={},
|
|
185
224
|
)
|
|
186
|
-
print(completion.
|
|
225
|
+
print(completion.debug_params)
|
|
187
226
|
```
|
|
188
227
|
|
|
189
228
|
## Handling errors
|
|
@@ -20,7 +20,46 @@ The full API of this library can be found in [api.md](api.md).
|
|
|
20
20
|
pip install perplexityai
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Search API
|
|
24
|
+
|
|
25
|
+
Get web search results:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import os
|
|
29
|
+
from perplexity import Perplexity
|
|
30
|
+
|
|
31
|
+
client = Perplexity(
|
|
32
|
+
api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
search = client.search.create(
|
|
36
|
+
query="latest AI developments 2024",
|
|
37
|
+
max_results=5
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
for result in search.results:
|
|
41
|
+
print(f"{result.title}: {result.url}")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Content API
|
|
45
|
+
|
|
46
|
+
Extract and process content from URLs:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from perplexity import Perplexity
|
|
50
|
+
|
|
51
|
+
client = Perplexity()
|
|
52
|
+
|
|
53
|
+
content = client.content.create(
|
|
54
|
+
urls=["https://en.wikipedia.org/wiki/Perplexity_AI"]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
for result in content.results:
|
|
58
|
+
print(f"Title: {result.title}")
|
|
59
|
+
print(f"Content: {result.content[:200]}...")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Chat Completions
|
|
24
63
|
|
|
25
64
|
The full API of this library can be found in [api.md](api.md).
|
|
26
65
|
|
|
@@ -145,10 +184,10 @@ completion = client.chat.completions.create(
|
|
|
145
184
|
"role": "system",
|
|
146
185
|
}
|
|
147
186
|
],
|
|
148
|
-
model="
|
|
149
|
-
|
|
187
|
+
model="model",
|
|
188
|
+
debug_params={},
|
|
150
189
|
)
|
|
151
|
-
print(completion.
|
|
190
|
+
print(completion.debug_params)
|
|
152
191
|
```
|
|
153
192
|
|
|
154
193
|
## Handling errors
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# Shared Types
|
|
2
2
|
|
|
3
3
|
```python
|
|
4
|
-
from perplexity.types import
|
|
4
|
+
from perplexity.types import (
|
|
5
|
+
APIPublicSearchResult,
|
|
6
|
+
ChatMessageInput,
|
|
7
|
+
ChatMessageOutput,
|
|
8
|
+
Choice,
|
|
9
|
+
UsageInfo,
|
|
10
|
+
)
|
|
5
11
|
```
|
|
6
12
|
|
|
7
13
|
# Chat
|
|
@@ -37,8 +43,8 @@ from perplexity.types.async_.chat import (
|
|
|
37
43
|
Methods:
|
|
38
44
|
|
|
39
45
|
- <code title="post /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">create</a>(\*\*<a href="src/perplexity/types/async_/chat/completion_create_params.py">params</a>) -> <a href="./src/perplexity/types/async_/chat/completion_create_response.py">CompletionCreateResponse</a></code>
|
|
40
|
-
- <code title="get /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">list</a>(
|
|
41
|
-
- <code title="get /async/chat/completions/{
|
|
46
|
+
- <code title="get /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">list</a>() -> <a href="./src/perplexity/types/async_/chat/completion_list_response.py">CompletionListResponse</a></code>
|
|
47
|
+
- <code title="get /async/chat/completions/{api_request}">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">get</a>(api*request, \*\*<a href="src/perplexity/types/async*/chat/completion*get_params.py">params</a>) -> <a href="./src/perplexity/types/async*/chat/completion_get_response.py">CompletionGetResponse</a></code>
|
|
42
48
|
|
|
43
49
|
# Search
|
|
44
50
|
|
{perplexityai-0.7.1 → perplexityai-0.8.0}/src/perplexity/resources/async_/chat/completions.py
RENAMED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
5
7
|
import httpx
|
|
6
8
|
|
|
7
9
|
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
8
|
-
from ...._utils import maybe_transform, async_maybe_transform
|
|
10
|
+
from ...._utils import maybe_transform, strip_not_given, async_maybe_transform
|
|
9
11
|
from ...._compat import cached_property
|
|
10
12
|
from ...._resource import SyncAPIResource, AsyncAPIResource
|
|
11
13
|
from ...._response import (
|
|
@@ -15,7 +17,7 @@ from ...._response import (
|
|
|
15
17
|
async_to_streamed_response_wrapper,
|
|
16
18
|
)
|
|
17
19
|
from ...._base_client import make_request_options
|
|
18
|
-
from ....types.async_.chat import
|
|
20
|
+
from ....types.async_.chat import completion_get_params, completion_create_params
|
|
19
21
|
from ....types.async_.chat.completion_get_response import CompletionGetResponse
|
|
20
22
|
from ....types.async_.chat.completion_list_response import CompletionListResponse
|
|
21
23
|
from ....types.async_.chat.completion_create_response import CompletionCreateResponse
|
|
@@ -47,6 +49,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
47
49
|
self,
|
|
48
50
|
*,
|
|
49
51
|
request: completion_create_params.Request,
|
|
52
|
+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
|
|
50
53
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
51
54
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
52
55
|
extra_headers: Headers | None = None,
|
|
@@ -55,7 +58,10 @@ class CompletionsResource(SyncAPIResource):
|
|
|
55
58
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
56
59
|
) -> CompletionCreateResponse:
|
|
57
60
|
"""
|
|
58
|
-
|
|
61
|
+
FastAPI wrapper around async chat completions
|
|
62
|
+
|
|
63
|
+
This endpoint creates an asynchronous chat completion job and returns a job ID
|
|
64
|
+
that can be used to poll for results.
|
|
59
65
|
|
|
60
66
|
Args:
|
|
61
67
|
extra_headers: Send extra headers
|
|
@@ -68,7 +74,13 @@ class CompletionsResource(SyncAPIResource):
|
|
|
68
74
|
"""
|
|
69
75
|
return self._post(
|
|
70
76
|
"/async/chat/completions",
|
|
71
|
-
body=maybe_transform(
|
|
77
|
+
body=maybe_transform(
|
|
78
|
+
{
|
|
79
|
+
"request": request,
|
|
80
|
+
"idempotency_key": idempotency_key,
|
|
81
|
+
},
|
|
82
|
+
completion_create_params.CompletionCreateParams,
|
|
83
|
+
),
|
|
72
84
|
options=make_request_options(
|
|
73
85
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
74
86
|
),
|
|
@@ -78,8 +90,6 @@ class CompletionsResource(SyncAPIResource):
|
|
|
78
90
|
def list(
|
|
79
91
|
self,
|
|
80
92
|
*,
|
|
81
|
-
limit: int | NotGiven = NOT_GIVEN,
|
|
82
|
-
next_token: str | NotGiven = NOT_GIVEN,
|
|
83
93
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
84
94
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
85
95
|
extra_headers: Headers | None = None,
|
|
@@ -87,44 +97,25 @@ class CompletionsResource(SyncAPIResource):
|
|
|
87
97
|
extra_body: Body | None = None,
|
|
88
98
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
89
99
|
) -> CompletionListResponse:
|
|
90
|
-
"""
|
|
91
|
-
Lists all asynchronous chat completion requests for the authenticated user
|
|
92
|
-
|
|
93
|
-
Args:
|
|
94
|
-
limit: Maximum number of requests to return
|
|
95
|
-
|
|
96
|
-
next_token: Token for fetching the next page of results
|
|
97
|
-
|
|
98
|
-
extra_headers: Send extra headers
|
|
99
|
-
|
|
100
|
-
extra_query: Add additional query parameters to the request
|
|
101
|
-
|
|
102
|
-
extra_body: Add additional JSON properties to the request
|
|
103
|
-
|
|
104
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
105
|
-
"""
|
|
100
|
+
"""list all async chat completion requests for a given user."""
|
|
106
101
|
return self._get(
|
|
107
102
|
"/async/chat/completions",
|
|
108
103
|
options=make_request_options(
|
|
109
|
-
extra_headers=extra_headers,
|
|
110
|
-
extra_query=extra_query,
|
|
111
|
-
extra_body=extra_body,
|
|
112
|
-
timeout=timeout,
|
|
113
|
-
query=maybe_transform(
|
|
114
|
-
{
|
|
115
|
-
"limit": limit,
|
|
116
|
-
"next_token": next_token,
|
|
117
|
-
},
|
|
118
|
-
completion_list_params.CompletionListParams,
|
|
119
|
-
),
|
|
104
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
120
105
|
),
|
|
121
106
|
cast_to=CompletionListResponse,
|
|
122
107
|
)
|
|
123
108
|
|
|
124
109
|
def get(
|
|
125
110
|
self,
|
|
126
|
-
|
|
111
|
+
api_request: str,
|
|
127
112
|
*,
|
|
113
|
+
local_mode: bool | NotGiven = NOT_GIVEN,
|
|
114
|
+
x_client_env: str | NotGiven = NOT_GIVEN,
|
|
115
|
+
x_client_name: str | NotGiven = NOT_GIVEN,
|
|
116
|
+
x_request_time: str | NotGiven = NOT_GIVEN,
|
|
117
|
+
x_usage_tier: str | NotGiven = NOT_GIVEN,
|
|
118
|
+
x_user_id: str | NotGiven = NOT_GIVEN,
|
|
128
119
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
129
120
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
130
121
|
extra_headers: Headers | None = None,
|
|
@@ -133,7 +124,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
133
124
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
134
125
|
) -> CompletionGetResponse:
|
|
135
126
|
"""
|
|
136
|
-
|
|
127
|
+
get the response for a given async chat completion request.
|
|
137
128
|
|
|
138
129
|
Args:
|
|
139
130
|
extra_headers: Send extra headers
|
|
@@ -144,12 +135,28 @@ class CompletionsResource(SyncAPIResource):
|
|
|
144
135
|
|
|
145
136
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
146
137
|
"""
|
|
147
|
-
if not
|
|
148
|
-
raise ValueError(f"Expected a non-empty value for `
|
|
138
|
+
if not api_request:
|
|
139
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
140
|
+
extra_headers = {
|
|
141
|
+
**strip_not_given(
|
|
142
|
+
{
|
|
143
|
+
"x-client-env": x_client_env,
|
|
144
|
+
"x-client-name": x_client_name,
|
|
145
|
+
"x-request-time": x_request_time,
|
|
146
|
+
"x-usage-tier": x_usage_tier,
|
|
147
|
+
"x-user-id": x_user_id,
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
**(extra_headers or {}),
|
|
151
|
+
}
|
|
149
152
|
return self._get(
|
|
150
|
-
f"/async/chat/completions/{
|
|
153
|
+
f"/async/chat/completions/{api_request}",
|
|
151
154
|
options=make_request_options(
|
|
152
|
-
extra_headers=extra_headers,
|
|
155
|
+
extra_headers=extra_headers,
|
|
156
|
+
extra_query=extra_query,
|
|
157
|
+
extra_body=extra_body,
|
|
158
|
+
timeout=timeout,
|
|
159
|
+
query=maybe_transform({"local_mode": local_mode}, completion_get_params.CompletionGetParams),
|
|
153
160
|
),
|
|
154
161
|
cast_to=CompletionGetResponse,
|
|
155
162
|
)
|
|
@@ -179,6 +186,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
179
186
|
self,
|
|
180
187
|
*,
|
|
181
188
|
request: completion_create_params.Request,
|
|
189
|
+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
|
|
182
190
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
183
191
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
184
192
|
extra_headers: Headers | None = None,
|
|
@@ -187,7 +195,10 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
187
195
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
188
196
|
) -> CompletionCreateResponse:
|
|
189
197
|
"""
|
|
190
|
-
|
|
198
|
+
FastAPI wrapper around async chat completions
|
|
199
|
+
|
|
200
|
+
This endpoint creates an asynchronous chat completion job and returns a job ID
|
|
201
|
+
that can be used to poll for results.
|
|
191
202
|
|
|
192
203
|
Args:
|
|
193
204
|
extra_headers: Send extra headers
|
|
@@ -200,7 +211,13 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
200
211
|
"""
|
|
201
212
|
return await self._post(
|
|
202
213
|
"/async/chat/completions",
|
|
203
|
-
body=await async_maybe_transform(
|
|
214
|
+
body=await async_maybe_transform(
|
|
215
|
+
{
|
|
216
|
+
"request": request,
|
|
217
|
+
"idempotency_key": idempotency_key,
|
|
218
|
+
},
|
|
219
|
+
completion_create_params.CompletionCreateParams,
|
|
220
|
+
),
|
|
204
221
|
options=make_request_options(
|
|
205
222
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
206
223
|
),
|
|
@@ -210,8 +227,6 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
210
227
|
async def list(
|
|
211
228
|
self,
|
|
212
229
|
*,
|
|
213
|
-
limit: int | NotGiven = NOT_GIVEN,
|
|
214
|
-
next_token: str | NotGiven = NOT_GIVEN,
|
|
215
230
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
216
231
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
217
232
|
extra_headers: Headers | None = None,
|
|
@@ -219,44 +234,25 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
219
234
|
extra_body: Body | None = None,
|
|
220
235
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
221
236
|
) -> CompletionListResponse:
|
|
222
|
-
"""
|
|
223
|
-
Lists all asynchronous chat completion requests for the authenticated user
|
|
224
|
-
|
|
225
|
-
Args:
|
|
226
|
-
limit: Maximum number of requests to return
|
|
227
|
-
|
|
228
|
-
next_token: Token for fetching the next page of results
|
|
229
|
-
|
|
230
|
-
extra_headers: Send extra headers
|
|
231
|
-
|
|
232
|
-
extra_query: Add additional query parameters to the request
|
|
233
|
-
|
|
234
|
-
extra_body: Add additional JSON properties to the request
|
|
235
|
-
|
|
236
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
237
|
-
"""
|
|
237
|
+
"""list all async chat completion requests for a given user."""
|
|
238
238
|
return await self._get(
|
|
239
239
|
"/async/chat/completions",
|
|
240
240
|
options=make_request_options(
|
|
241
|
-
extra_headers=extra_headers,
|
|
242
|
-
extra_query=extra_query,
|
|
243
|
-
extra_body=extra_body,
|
|
244
|
-
timeout=timeout,
|
|
245
|
-
query=await async_maybe_transform(
|
|
246
|
-
{
|
|
247
|
-
"limit": limit,
|
|
248
|
-
"next_token": next_token,
|
|
249
|
-
},
|
|
250
|
-
completion_list_params.CompletionListParams,
|
|
251
|
-
),
|
|
241
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
252
242
|
),
|
|
253
243
|
cast_to=CompletionListResponse,
|
|
254
244
|
)
|
|
255
245
|
|
|
256
246
|
async def get(
|
|
257
247
|
self,
|
|
258
|
-
|
|
248
|
+
api_request: str,
|
|
259
249
|
*,
|
|
250
|
+
local_mode: bool | NotGiven = NOT_GIVEN,
|
|
251
|
+
x_client_env: str | NotGiven = NOT_GIVEN,
|
|
252
|
+
x_client_name: str | NotGiven = NOT_GIVEN,
|
|
253
|
+
x_request_time: str | NotGiven = NOT_GIVEN,
|
|
254
|
+
x_usage_tier: str | NotGiven = NOT_GIVEN,
|
|
255
|
+
x_user_id: str | NotGiven = NOT_GIVEN,
|
|
260
256
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
261
257
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
262
258
|
extra_headers: Headers | None = None,
|
|
@@ -265,7 +261,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
265
261
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
266
262
|
) -> CompletionGetResponse:
|
|
267
263
|
"""
|
|
268
|
-
|
|
264
|
+
get the response for a given async chat completion request.
|
|
269
265
|
|
|
270
266
|
Args:
|
|
271
267
|
extra_headers: Send extra headers
|
|
@@ -276,12 +272,30 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
276
272
|
|
|
277
273
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
278
274
|
"""
|
|
279
|
-
if not
|
|
280
|
-
raise ValueError(f"Expected a non-empty value for `
|
|
275
|
+
if not api_request:
|
|
276
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
277
|
+
extra_headers = {
|
|
278
|
+
**strip_not_given(
|
|
279
|
+
{
|
|
280
|
+
"x-client-env": x_client_env,
|
|
281
|
+
"x-client-name": x_client_name,
|
|
282
|
+
"x-request-time": x_request_time,
|
|
283
|
+
"x-usage-tier": x_usage_tier,
|
|
284
|
+
"x-user-id": x_user_id,
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
**(extra_headers or {}),
|
|
288
|
+
}
|
|
281
289
|
return await self._get(
|
|
282
|
-
f"/async/chat/completions/{
|
|
290
|
+
f"/async/chat/completions/{api_request}",
|
|
283
291
|
options=make_request_options(
|
|
284
|
-
extra_headers=extra_headers,
|
|
292
|
+
extra_headers=extra_headers,
|
|
293
|
+
extra_query=extra_query,
|
|
294
|
+
extra_body=extra_body,
|
|
295
|
+
timeout=timeout,
|
|
296
|
+
query=await async_maybe_transform(
|
|
297
|
+
{"local_mode": local_mode}, completion_get_params.CompletionGetParams
|
|
298
|
+
),
|
|
285
299
|
),
|
|
286
300
|
cast_to=CompletionGetResponse,
|
|
287
301
|
)
|