orq-ai-sdk 4.2.0rc49__py3-none-any.whl → 4.2.12__py3-none-any.whl
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.
- orq_ai_sdk/_hooks/globalhook.py +0 -1
- orq_ai_sdk/_version.py +3 -3
- orq_ai_sdk/audio.py +30 -0
- orq_ai_sdk/chat.py +22 -0
- orq_ai_sdk/completions.py +438 -0
- orq_ai_sdk/contacts.py +43 -886
- orq_ai_sdk/deployments.py +61 -0
- orq_ai_sdk/edits.py +364 -0
- orq_ai_sdk/embeddings.py +344 -0
- orq_ai_sdk/generations.py +370 -0
- orq_ai_sdk/images.py +28 -0
- orq_ai_sdk/models/__init__.py +3839 -424
- orq_ai_sdk/models/conversationresponse.py +1 -1
- orq_ai_sdk/models/conversationwithmessagesresponse.py +1 -1
- orq_ai_sdk/models/createagentrequestop.py +768 -12
- orq_ai_sdk/models/createagentresponse.py +68 -2
- orq_ai_sdk/models/createchatcompletionop.py +538 -313
- orq_ai_sdk/models/createcompletionop.py +2078 -0
- orq_ai_sdk/models/createcontactop.py +5 -10
- orq_ai_sdk/models/createconversationop.py +1 -1
- orq_ai_sdk/models/createconversationresponseop.py +2 -2
- orq_ai_sdk/models/createdatasetitemop.py +4 -4
- orq_ai_sdk/models/createdatasetop.py +1 -1
- orq_ai_sdk/models/createdatasourceop.py +1 -1
- orq_ai_sdk/models/createembeddingop.py +579 -0
- orq_ai_sdk/models/createevalop.py +14 -14
- orq_ai_sdk/models/createidentityop.py +1 -1
- orq_ai_sdk/models/createimageeditop.py +715 -0
- orq_ai_sdk/models/createimageop.py +228 -82
- orq_ai_sdk/models/createimagevariationop.py +706 -0
- orq_ai_sdk/models/creatememoryop.py +4 -2
- orq_ai_sdk/models/createmoderationop.py +521 -0
- orq_ai_sdk/models/createpromptop.py +375 -6
- orq_ai_sdk/models/creatererankop.py +608 -0
- orq_ai_sdk/models/createresponseop.py +2567 -0
- orq_ai_sdk/models/createspeechop.py +466 -0
- orq_ai_sdk/models/createtoolop.py +6 -6
- orq_ai_sdk/models/createtranscriptionop.py +732 -0
- orq_ai_sdk/models/createtranslationop.py +702 -0
- orq_ai_sdk/models/deploymentgetconfigop.py +17 -7
- orq_ai_sdk/models/deploymentsop.py +1 -0
- orq_ai_sdk/models/deploymentstreamop.py +7 -0
- orq_ai_sdk/models/filegetop.py +1 -1
- orq_ai_sdk/models/filelistop.py +1 -1
- orq_ai_sdk/models/fileuploadop.py +1 -1
- orq_ai_sdk/models/generateconversationnameop.py +1 -1
- orq_ai_sdk/models/getallmemoriesop.py +4 -2
- orq_ai_sdk/models/getallpromptsop.py +188 -3
- orq_ai_sdk/models/getalltoolsop.py +6 -6
- orq_ai_sdk/models/getevalsop.py +17 -17
- orq_ai_sdk/models/getonepromptop.py +188 -3
- orq_ai_sdk/models/getpromptversionop.py +188 -3
- orq_ai_sdk/models/invokedeploymentrequest.py +11 -4
- orq_ai_sdk/models/listagentsop.py +372 -0
- orq_ai_sdk/models/listdatasetdatapointsop.py +4 -4
- orq_ai_sdk/models/listdatasetsop.py +1 -1
- orq_ai_sdk/models/listdatasourcesop.py +1 -1
- orq_ai_sdk/models/listidentitiesop.py +1 -1
- orq_ai_sdk/models/listmodelsop.py +1 -0
- orq_ai_sdk/models/listpromptversionsop.py +188 -3
- orq_ai_sdk/models/partdoneevent.py +1 -1
- orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
- orq_ai_sdk/models/publiccontact.py +9 -3
- orq_ai_sdk/models/publicidentity.py +62 -0
- orq_ai_sdk/models/reasoningpart.py +1 -1
- orq_ai_sdk/models/responsedoneevent.py +14 -11
- orq_ai_sdk/models/retrieveagentrequestop.py +382 -0
- orq_ai_sdk/models/retrievedatapointop.py +4 -4
- orq_ai_sdk/models/retrievedatasetop.py +1 -1
- orq_ai_sdk/models/retrievedatasourceop.py +1 -1
- orq_ai_sdk/models/retrieveidentityop.py +1 -1
- orq_ai_sdk/models/retrievememoryop.py +4 -2
- orq_ai_sdk/models/retrievetoolop.py +6 -6
- orq_ai_sdk/models/runagentop.py +379 -9
- orq_ai_sdk/models/streamrunagentop.py +385 -9
- orq_ai_sdk/models/updateagentop.py +770 -12
- orq_ai_sdk/models/updateconversationop.py +1 -1
- orq_ai_sdk/models/updatedatapointop.py +4 -4
- orq_ai_sdk/models/updatedatasetop.py +1 -1
- orq_ai_sdk/models/updatedatasourceop.py +1 -1
- orq_ai_sdk/models/updateevalop.py +14 -14
- orq_ai_sdk/models/updateidentityop.py +1 -1
- orq_ai_sdk/models/updatememoryop.py +4 -2
- orq_ai_sdk/models/updatepromptop.py +375 -6
- orq_ai_sdk/models/updatetoolop.py +7 -7
- orq_ai_sdk/moderations.py +218 -0
- orq_ai_sdk/orq_completions.py +666 -0
- orq_ai_sdk/orq_responses.py +398 -0
- orq_ai_sdk/rerank.py +330 -0
- orq_ai_sdk/router.py +89 -641
- orq_ai_sdk/speech.py +333 -0
- orq_ai_sdk/transcriptions.py +416 -0
- orq_ai_sdk/translations.py +384 -0
- orq_ai_sdk/variations.py +364 -0
- orq_ai_sdk-4.2.12.dist-info/METADATA +888 -0
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/RECORD +98 -75
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/WHEEL +1 -1
- orq_ai_sdk/models/deletecontactop.py +0 -44
- orq_ai_sdk/models/listcontactsop.py +0 -265
- orq_ai_sdk/models/retrievecontactop.py +0 -142
- orq_ai_sdk/models/updatecontactop.py +0 -233
- orq_ai_sdk-4.2.0rc49.dist-info/METADATA +0 -788
- {orq_ai_sdk-4.2.0rc49.dist-info → orq_ai_sdk-4.2.12.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: orq-ai-sdk
|
|
3
|
+
Version: 4.2.12
|
|
4
|
+
Summary: Python Client SDK for the Orq API.
|
|
5
|
+
Author: Orq
|
|
6
|
+
Project-URL: repository, https://github.com/orq-ai/orq-python.git
|
|
7
|
+
Requires-Python: >=3.9.2
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: httpcore>=1.0.9
|
|
10
|
+
Requires-Dist: httpx>=0.28.1
|
|
11
|
+
Requires-Dist: pydantic>=2.11.2
|
|
12
|
+
Requires-Dist: requests==2.32.4
|
|
13
|
+
|
|
14
|
+
# orq-ai-sdk
|
|
15
|
+
|
|
16
|
+
Developer-friendly & type-safe Python SDK specifically catered to leverage *orq-ai-sdk* API.
|
|
17
|
+
|
|
18
|
+
<div align="left">
|
|
19
|
+
<a href="https://www.speakeasy.com/?utm_source=orq-ai-sdk&utm_campaign=python"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
20
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
21
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<!-- Start Summary [summary] -->
|
|
26
|
+
## Summary
|
|
27
|
+
|
|
28
|
+
orq.ai API: orq.ai API documentation
|
|
29
|
+
|
|
30
|
+
For more information about the API: [orq.ai Documentation](https://docs.orq.ai)
|
|
31
|
+
<!-- End Summary [summary] -->
|
|
32
|
+
|
|
33
|
+
<!-- Start Table of Contents [toc] -->
|
|
34
|
+
## Table of Contents
|
|
35
|
+
<!-- $toc-max-depth=2 -->
|
|
36
|
+
* [orq-ai-sdk](https://github.com/orq-ai/orq-python/blob/master/#orq-ai-sdk)
|
|
37
|
+
* [SDK Installation](https://github.com/orq-ai/orq-python/blob/master/#sdk-installation)
|
|
38
|
+
* [IDE Support](https://github.com/orq-ai/orq-python/blob/master/#ide-support)
|
|
39
|
+
* [SDK Example Usage](https://github.com/orq-ai/orq-python/blob/master/#sdk-example-usage)
|
|
40
|
+
* [Authentication](https://github.com/orq-ai/orq-python/blob/master/#authentication)
|
|
41
|
+
* [Available Resources and Operations](https://github.com/orq-ai/orq-python/blob/master/#available-resources-and-operations)
|
|
42
|
+
* [Server-sent event streaming](https://github.com/orq-ai/orq-python/blob/master/#server-sent-event-streaming)
|
|
43
|
+
* [File uploads](https://github.com/orq-ai/orq-python/blob/master/#file-uploads)
|
|
44
|
+
* [Retries](https://github.com/orq-ai/orq-python/blob/master/#retries)
|
|
45
|
+
* [Error Handling](https://github.com/orq-ai/orq-python/blob/master/#error-handling)
|
|
46
|
+
* [Server Selection](https://github.com/orq-ai/orq-python/blob/master/#server-selection)
|
|
47
|
+
* [Custom HTTP Client](https://github.com/orq-ai/orq-python/blob/master/#custom-http-client)
|
|
48
|
+
* [Resource Management](https://github.com/orq-ai/orq-python/blob/master/#resource-management)
|
|
49
|
+
* [Debugging](https://github.com/orq-ai/orq-python/blob/master/#debugging)
|
|
50
|
+
* [Development](https://github.com/orq-ai/orq-python/blob/master/#development)
|
|
51
|
+
* [Maturity](https://github.com/orq-ai/orq-python/blob/master/#maturity)
|
|
52
|
+
* [Contributions](https://github.com/orq-ai/orq-python/blob/master/#contributions)
|
|
53
|
+
|
|
54
|
+
<!-- End Table of Contents [toc] -->
|
|
55
|
+
|
|
56
|
+
<!-- Start SDK Installation [installation] -->
|
|
57
|
+
## SDK Installation
|
|
58
|
+
|
|
59
|
+
> [!NOTE]
|
|
60
|
+
> **Python version upgrade policy**
|
|
61
|
+
>
|
|
62
|
+
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
|
|
63
|
+
|
|
64
|
+
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
|
|
65
|
+
|
|
66
|
+
### uv
|
|
67
|
+
|
|
68
|
+
*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
uv add orq-ai-sdk
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### PIP
|
|
75
|
+
|
|
76
|
+
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install orq-ai-sdk
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Poetry
|
|
83
|
+
|
|
84
|
+
*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
poetry add orq-ai-sdk
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Shell and script usage with `uv`
|
|
91
|
+
|
|
92
|
+
You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
|
|
93
|
+
|
|
94
|
+
```shell
|
|
95
|
+
uvx --from orq-ai-sdk python
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
It's also possible to write a standalone Python script without needing to set up a whole project like so:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
#!/usr/bin/env -S uv run --script
|
|
102
|
+
# /// script
|
|
103
|
+
# requires-python = ">=3.9"
|
|
104
|
+
# dependencies = [
|
|
105
|
+
# "orq-ai-sdk",
|
|
106
|
+
# ]
|
|
107
|
+
# ///
|
|
108
|
+
|
|
109
|
+
from orq_ai_sdk import Orq
|
|
110
|
+
|
|
111
|
+
sdk = Orq(
|
|
112
|
+
# SDK arguments
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Rest of script here...
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Once that is saved to a file, you can run it with `uv run script.py` where
|
|
119
|
+
`script.py` can be replaced with the actual file name.
|
|
120
|
+
<!-- End SDK Installation [installation] -->
|
|
121
|
+
|
|
122
|
+
<!-- Start IDE Support [idesupport] -->
|
|
123
|
+
## IDE Support
|
|
124
|
+
|
|
125
|
+
### PyCharm
|
|
126
|
+
|
|
127
|
+
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
|
|
128
|
+
|
|
129
|
+
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
|
130
|
+
<!-- End IDE Support [idesupport] -->
|
|
131
|
+
|
|
132
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
133
|
+
## SDK Example Usage
|
|
134
|
+
|
|
135
|
+
### Example
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
# Synchronous Example
|
|
139
|
+
from orq_ai_sdk import Orq
|
|
140
|
+
import os
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
with Orq(
|
|
144
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
145
|
+
) as orq:
|
|
146
|
+
|
|
147
|
+
res = orq.contacts.create(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
148
|
+
"premium",
|
|
149
|
+
"beta-user",
|
|
150
|
+
"enterprise",
|
|
151
|
+
], metadata={
|
|
152
|
+
"department": "Engineering",
|
|
153
|
+
"role": "Senior Developer",
|
|
154
|
+
"subscription_tier": "premium",
|
|
155
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
# Handle response
|
|
159
|
+
print(res)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
</br>
|
|
163
|
+
|
|
164
|
+
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
# Asynchronous Example
|
|
168
|
+
import asyncio
|
|
169
|
+
from orq_ai_sdk import Orq
|
|
170
|
+
import os
|
|
171
|
+
|
|
172
|
+
async def main():
|
|
173
|
+
|
|
174
|
+
async with Orq(
|
|
175
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
176
|
+
) as orq:
|
|
177
|
+
|
|
178
|
+
res = await orq.contacts.create_async(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
179
|
+
"premium",
|
|
180
|
+
"beta-user",
|
|
181
|
+
"enterprise",
|
|
182
|
+
], metadata={
|
|
183
|
+
"department": "Engineering",
|
|
184
|
+
"role": "Senior Developer",
|
|
185
|
+
"subscription_tier": "premium",
|
|
186
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
# Handle response
|
|
190
|
+
print(res)
|
|
191
|
+
|
|
192
|
+
asyncio.run(main())
|
|
193
|
+
```
|
|
194
|
+
<!-- End SDK Example Usage [usage] -->
|
|
195
|
+
|
|
196
|
+
<!-- Start Authentication [security] -->
|
|
197
|
+
## Authentication
|
|
198
|
+
|
|
199
|
+
### Per-Client Security Schemes
|
|
200
|
+
|
|
201
|
+
This SDK supports the following security scheme globally:
|
|
202
|
+
|
|
203
|
+
| Name | Type | Scheme | Environment Variable |
|
|
204
|
+
| --------- | ---- | ----------- | -------------------- |
|
|
205
|
+
| `api_key` | http | HTTP Bearer | `ORQ_API_KEY` |
|
|
206
|
+
|
|
207
|
+
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
|
208
|
+
```python
|
|
209
|
+
from orq_ai_sdk import Orq
|
|
210
|
+
import os
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
with Orq(
|
|
214
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
215
|
+
) as orq:
|
|
216
|
+
|
|
217
|
+
res = orq.contacts.create(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
218
|
+
"premium",
|
|
219
|
+
"beta-user",
|
|
220
|
+
"enterprise",
|
|
221
|
+
], metadata={
|
|
222
|
+
"department": "Engineering",
|
|
223
|
+
"role": "Senior Developer",
|
|
224
|
+
"subscription_tier": "premium",
|
|
225
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
# Handle response
|
|
229
|
+
print(res)
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
<!-- End Authentication [security] -->
|
|
233
|
+
|
|
234
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
235
|
+
## Available Resources and Operations
|
|
236
|
+
|
|
237
|
+
<details open>
|
|
238
|
+
<summary>Available methods</summary>
|
|
239
|
+
|
|
240
|
+
### [Agents](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md)
|
|
241
|
+
|
|
242
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#create) - Create agent
|
|
243
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#delete) - Delete agent
|
|
244
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#retrieve) - Retrieve agent
|
|
245
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#update) - Update agent
|
|
246
|
+
* [~~invoke~~](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#invoke) - Execute an agent task :warning: **Deprecated**
|
|
247
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#list) - List agents
|
|
248
|
+
* [~~run~~](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#run) - Run an agent with configuration :warning: **Deprecated**
|
|
249
|
+
* [~~stream_run~~](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#stream_run) - Run agent with streaming response :warning: **Deprecated**
|
|
250
|
+
* [~~stream~~](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/agents/README.md#stream) - Stream agent execution in real-time :warning: **Deprecated**
|
|
251
|
+
|
|
252
|
+
#### [Agents.Responses](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/responses/README.md)
|
|
253
|
+
|
|
254
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/responses/README.md#create) - Create response
|
|
255
|
+
|
|
256
|
+
### [Chunking](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/chunking/README.md)
|
|
257
|
+
|
|
258
|
+
* [parse](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/chunking/README.md#parse) - Parse text
|
|
259
|
+
|
|
260
|
+
### [Contacts](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/contacts/README.md)
|
|
261
|
+
|
|
262
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/contacts/README.md#create) - Update user information
|
|
263
|
+
|
|
264
|
+
### [Conversations](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md)
|
|
265
|
+
|
|
266
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#list) - List conversations
|
|
267
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#create) - Create conversation
|
|
268
|
+
* [generate_name](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#generate_name) - Generate conversation name
|
|
269
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#retrieve) - Retrieve conversation
|
|
270
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#update) - Update conversation
|
|
271
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#delete) - Delete conversation
|
|
272
|
+
* [create_conversation_response](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/conversations/README.md#create_conversation_response) - Create internal response
|
|
273
|
+
|
|
274
|
+
### [Datasets](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md)
|
|
275
|
+
|
|
276
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#list) - List datasets
|
|
277
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#create) - Create a dataset
|
|
278
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#retrieve) - Retrieve a dataset
|
|
279
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#update) - Update a dataset
|
|
280
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#delete) - Delete a dataset
|
|
281
|
+
* [list_datapoints](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#list_datapoints) - List datapoints
|
|
282
|
+
* [create_datapoint](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#create_datapoint) - Create a datapoint
|
|
283
|
+
* [retrieve_datapoint](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#retrieve_datapoint) - Retrieve a datapoint
|
|
284
|
+
* [update_datapoint](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#update_datapoint) - Update a datapoint
|
|
285
|
+
* [delete_datapoint](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#delete_datapoint) - Delete a datapoint
|
|
286
|
+
* [clear](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/datasets/README.md#clear) - Delete all datapoints
|
|
287
|
+
|
|
288
|
+
### [Deployments](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/deployments/README.md)
|
|
289
|
+
|
|
290
|
+
* [invoke](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/deployments/README.md#invoke) - Invoke
|
|
291
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/deployments/README.md#list) - List all deployments
|
|
292
|
+
* [get_config](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/deployments/README.md#get_config) - Get config
|
|
293
|
+
* [stream](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/deployments/README.md#stream) - Stream
|
|
294
|
+
|
|
295
|
+
#### [Deployments.Metrics](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/metrics/README.md)
|
|
296
|
+
|
|
297
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/metrics/README.md#create) - Add metrics
|
|
298
|
+
|
|
299
|
+
### [Evals](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md)
|
|
300
|
+
|
|
301
|
+
* [all](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md#all) - Get all Evaluators
|
|
302
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md#create) - Create an Evaluator
|
|
303
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md#update) - Update an Evaluator
|
|
304
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md#delete) - Delete an Evaluator
|
|
305
|
+
* [invoke](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evals/README.md#invoke) - Invoke a Custom Evaluator
|
|
306
|
+
|
|
307
|
+
### [Evaluators](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evaluators/README.md)
|
|
308
|
+
|
|
309
|
+
* [get_v2_evaluators_id_versions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/evaluators/README.md#get_v2_evaluators_id_versions) - List evaluator versions
|
|
310
|
+
|
|
311
|
+
### [Feedback](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/feedback/README.md)
|
|
312
|
+
|
|
313
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/feedback/README.md#create) - Submit feedback
|
|
314
|
+
|
|
315
|
+
### [Files](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/files/README.md)
|
|
316
|
+
|
|
317
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/files/README.md#create) - Create file
|
|
318
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/files/README.md#list) - List all files
|
|
319
|
+
* [get](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/files/README.md#get) - Retrieve a file
|
|
320
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/files/README.md#delete) - Delete file
|
|
321
|
+
|
|
322
|
+
### [Identities](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md)
|
|
323
|
+
|
|
324
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md#list) - List identities
|
|
325
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md#create) - Create an identity
|
|
326
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md#retrieve) - Retrieve an identity
|
|
327
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md#update) - Update an identity
|
|
328
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/identities/README.md#delete) - Delete an identity
|
|
329
|
+
|
|
330
|
+
### [Internal](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/internal/README.md)
|
|
331
|
+
|
|
332
|
+
* [create_conversation_response](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/internal/README.md#create_conversation_response) - Create internal response
|
|
333
|
+
|
|
334
|
+
### [Knowledge](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md)
|
|
335
|
+
|
|
336
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#list) - List all knowledge bases
|
|
337
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#create) - Create a knowledge
|
|
338
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#retrieve) - Retrieves a knowledge base
|
|
339
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#update) - Updates a knowledge
|
|
340
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#delete) - Deletes a knowledge
|
|
341
|
+
* [search](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#search) - Search knowledge base
|
|
342
|
+
* [list_datasources](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#list_datasources) - List all datasources
|
|
343
|
+
* [create_datasource](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#create_datasource) - Create a new datasource
|
|
344
|
+
* [retrieve_datasource](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#retrieve_datasource) - Retrieve a datasource
|
|
345
|
+
* [delete_datasource](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#delete_datasource) - Deletes a datasource
|
|
346
|
+
* [update_datasource](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#update_datasource) - Update a datasource
|
|
347
|
+
* [create_chunks](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#create_chunks) - Create chunks for a datasource
|
|
348
|
+
* [list_chunks](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#list_chunks) - List all chunks for a datasource
|
|
349
|
+
* [delete_chunks](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#delete_chunks) - Delete multiple chunks
|
|
350
|
+
* [list_chunks_paginated](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#list_chunks_paginated) - List chunks with offset-based pagination
|
|
351
|
+
* [get_chunks_count](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#get_chunks_count) - Get chunks total count
|
|
352
|
+
* [update_chunk](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#update_chunk) - Update a chunk
|
|
353
|
+
* [delete_chunk](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#delete_chunk) - Delete a chunk
|
|
354
|
+
* [retrieve_chunk](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/knowledge/README.md#retrieve_chunk) - Retrieve a chunk
|
|
355
|
+
|
|
356
|
+
### [MemoryStores](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md)
|
|
357
|
+
|
|
358
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#list) - List memory stores
|
|
359
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#create) - Create memory store
|
|
360
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#retrieve) - Retrieve memory store
|
|
361
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#update) - Update memory store
|
|
362
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#delete) - Delete memory store
|
|
363
|
+
* [list_memories](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#list_memories) - List all memories
|
|
364
|
+
* [create_memory](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#create_memory) - Create a new memory
|
|
365
|
+
* [retrieve_memory](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#retrieve_memory) - Retrieve a specific memory
|
|
366
|
+
* [update_memory](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#update_memory) - Update a specific memory
|
|
367
|
+
* [delete_memory](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#delete_memory) - Delete a specific memory
|
|
368
|
+
* [list_documents](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#list_documents) - List all documents for a memory
|
|
369
|
+
* [create_document](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#create_document) - Create a new memory document
|
|
370
|
+
* [retrieve_document](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#retrieve_document) - Retrieve a specific memory document
|
|
371
|
+
* [update_document](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#update_document) - Update a specific memory document
|
|
372
|
+
* [delete_document](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/memorystores/README.md#delete_document) - Delete a specific memory document
|
|
373
|
+
|
|
374
|
+
### [Models](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/models/README.md)
|
|
375
|
+
|
|
376
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/models/README.md#list) - List models
|
|
377
|
+
|
|
378
|
+
### [Prompts](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md)
|
|
379
|
+
|
|
380
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#list) - List all prompts
|
|
381
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#create) - Create a prompt
|
|
382
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#retrieve) - Retrieve a prompt
|
|
383
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#update) - Update a prompt
|
|
384
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#delete) - Delete a prompt
|
|
385
|
+
* [list_versions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#list_versions) - List all prompt versions
|
|
386
|
+
* [get_version](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/prompts/README.md#get_version) - Retrieve a prompt version
|
|
387
|
+
|
|
388
|
+
### [Remoteconfigs](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/remoteconfigs/README.md)
|
|
389
|
+
|
|
390
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/remoteconfigs/README.md#retrieve) - Retrieve a remote config
|
|
391
|
+
|
|
392
|
+
### [Router](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/router/README.md)
|
|
393
|
+
|
|
394
|
+
* [ocr](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/router/README.md#ocr) - Extracts text content while maintaining document structure and hierarchy
|
|
395
|
+
|
|
396
|
+
#### [Router.Audio.Speech](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/speech/README.md)
|
|
397
|
+
|
|
398
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/speech/README.md#create) - Create speech
|
|
399
|
+
|
|
400
|
+
#### [Router.Audio.Transcriptions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/transcriptions/README.md)
|
|
401
|
+
|
|
402
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/transcriptions/README.md#create) - Create transcription
|
|
403
|
+
|
|
404
|
+
#### [Router.Audio.Translations](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/translations/README.md)
|
|
405
|
+
|
|
406
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/translations/README.md#create) - Create translation
|
|
407
|
+
|
|
408
|
+
#### [Router.Chat.Completions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/orqcompletions/README.md)
|
|
409
|
+
|
|
410
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/orqcompletions/README.md#create) - Create chat completion
|
|
411
|
+
|
|
412
|
+
#### [Router.Completions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/completions/README.md)
|
|
413
|
+
|
|
414
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/completions/README.md#create) - Create completion
|
|
415
|
+
|
|
416
|
+
#### [Router.Embeddings](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/embeddings/README.md)
|
|
417
|
+
|
|
418
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/embeddings/README.md#create) - Create embeddings
|
|
419
|
+
|
|
420
|
+
#### [Router.Images.Edits](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/edits/README.md)
|
|
421
|
+
|
|
422
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/edits/README.md#create) - Create image edit
|
|
423
|
+
|
|
424
|
+
#### [Router.Images.Generations](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/generations/README.md)
|
|
425
|
+
|
|
426
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/generations/README.md#create) - Create image
|
|
427
|
+
|
|
428
|
+
#### [Router.Images.Variations](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/variations/README.md)
|
|
429
|
+
|
|
430
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/variations/README.md#create) - Create image variation
|
|
431
|
+
|
|
432
|
+
#### [Router.Moderations](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/moderations/README.md)
|
|
433
|
+
|
|
434
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/moderations/README.md#create) - Create moderation
|
|
435
|
+
|
|
436
|
+
#### [Router.Rerank](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/rerank/README.md)
|
|
437
|
+
|
|
438
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/rerank/README.md#create) - Create rerank
|
|
439
|
+
|
|
440
|
+
#### [Router.Responses](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/orqresponses/README.md)
|
|
441
|
+
|
|
442
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/orqresponses/README.md#create) - Create response
|
|
443
|
+
|
|
444
|
+
### [Tools](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md)
|
|
445
|
+
|
|
446
|
+
* [list](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#list) - List tools
|
|
447
|
+
* [create](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#create) - Create tool
|
|
448
|
+
* [update](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#update) - Update tool
|
|
449
|
+
* [delete](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#delete) - Delete tool
|
|
450
|
+
* [retrieve](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#retrieve) - Retrieve tool
|
|
451
|
+
* [get_v2_tools_tool_id_versions](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#get_v2_tools_tool_id_versions) - List tool versions
|
|
452
|
+
* [get_v2_tools_tool_id_versions_version_id_](https://github.com/orq-ai/orq-python/blob/master/docs/sdks/tools/README.md#get_v2_tools_tool_id_versions_version_id_) - Get tool version
|
|
453
|
+
|
|
454
|
+
</details>
|
|
455
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
456
|
+
|
|
457
|
+
<!-- Start Server-sent event streaming [eventstream] -->
|
|
458
|
+
## Server-sent event streaming
|
|
459
|
+
|
|
460
|
+
[Server-sent events][mdn-sse] are used to stream content from certain
|
|
461
|
+
operations. These operations will expose the stream as [Generator][generator] that
|
|
462
|
+
can be consumed using a simple `for` loop. The loop will
|
|
463
|
+
terminate when the server no longer has any events to send and closes the
|
|
464
|
+
underlying connection.
|
|
465
|
+
|
|
466
|
+
The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the
|
|
467
|
+
underlying connection when the context is exited.
|
|
468
|
+
|
|
469
|
+
```python
|
|
470
|
+
from orq_ai_sdk import Orq
|
|
471
|
+
import os
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
with Orq(
|
|
475
|
+
environment="<value>",
|
|
476
|
+
contact_id="<id>",
|
|
477
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
478
|
+
) as orq:
|
|
479
|
+
|
|
480
|
+
res = orq.deployments.stream(key="<key>", identity={
|
|
481
|
+
"id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV",
|
|
482
|
+
"display_name": "Jane Doe",
|
|
483
|
+
"email": "jane.doe@example.com",
|
|
484
|
+
"metadata": [
|
|
485
|
+
{
|
|
486
|
+
"department": "Engineering",
|
|
487
|
+
"role": "Senior Developer",
|
|
488
|
+
},
|
|
489
|
+
],
|
|
490
|
+
"logo_url": "https://example.com/avatars/jane-doe.jpg",
|
|
491
|
+
"tags": [
|
|
492
|
+
"hr",
|
|
493
|
+
"engineering",
|
|
494
|
+
],
|
|
495
|
+
}, documents=[
|
|
496
|
+
{
|
|
497
|
+
"text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.",
|
|
498
|
+
"metadata": {
|
|
499
|
+
"file_name": "refund_policy.pdf",
|
|
500
|
+
"file_type": "application/pdf",
|
|
501
|
+
"page_number": 1,
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
"text": "Premium members receive free shipping on all orders over $50.",
|
|
506
|
+
"metadata": {
|
|
507
|
+
"file_name": "membership_benefits.md",
|
|
508
|
+
"file_type": "text/markdown",
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
])
|
|
512
|
+
|
|
513
|
+
with res as event_stream:
|
|
514
|
+
for event in event_stream:
|
|
515
|
+
# handle event
|
|
516
|
+
print(event, flush=True)
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
|
|
521
|
+
[generator]: https://book.pythontips.com/en/latest/generators.html
|
|
522
|
+
[context-manager]: https://book.pythontips.com/en/latest/context_managers.html
|
|
523
|
+
<!-- End Server-sent event streaming [eventstream] -->
|
|
524
|
+
|
|
525
|
+
<!-- Start File uploads [file-upload] -->
|
|
526
|
+
## File uploads
|
|
527
|
+
|
|
528
|
+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
|
|
529
|
+
|
|
530
|
+
> [!TIP]
|
|
531
|
+
>
|
|
532
|
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
|
|
533
|
+
>
|
|
534
|
+
|
|
535
|
+
```python
|
|
536
|
+
from orq_ai_sdk import Orq
|
|
537
|
+
import os
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
with Orq(
|
|
541
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
542
|
+
) as orq:
|
|
543
|
+
|
|
544
|
+
res = orq.files.create(file={
|
|
545
|
+
"file_name": "example.file",
|
|
546
|
+
"content": open("example.file", "rb"),
|
|
547
|
+
}, purpose="retrieval")
|
|
548
|
+
|
|
549
|
+
# Handle response
|
|
550
|
+
print(res)
|
|
551
|
+
|
|
552
|
+
```
|
|
553
|
+
<!-- End File uploads [file-upload] -->
|
|
554
|
+
|
|
555
|
+
<!-- Start Retries [retries] -->
|
|
556
|
+
## Retries
|
|
557
|
+
|
|
558
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
559
|
+
|
|
560
|
+
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
|
561
|
+
```python
|
|
562
|
+
from orq_ai_sdk import Orq
|
|
563
|
+
from orq_ai_sdk.utils import BackoffStrategy, RetryConfig
|
|
564
|
+
import os
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
with Orq(
|
|
568
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
569
|
+
) as orq:
|
|
570
|
+
|
|
571
|
+
res = orq.contacts.create(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
572
|
+
"premium",
|
|
573
|
+
"beta-user",
|
|
574
|
+
"enterprise",
|
|
575
|
+
], metadata={
|
|
576
|
+
"department": "Engineering",
|
|
577
|
+
"role": "Senior Developer",
|
|
578
|
+
"subscription_tier": "premium",
|
|
579
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
580
|
+
},
|
|
581
|
+
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
582
|
+
|
|
583
|
+
# Handle response
|
|
584
|
+
print(res)
|
|
585
|
+
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
|
589
|
+
```python
|
|
590
|
+
from orq_ai_sdk import Orq
|
|
591
|
+
from orq_ai_sdk.utils import BackoffStrategy, RetryConfig
|
|
592
|
+
import os
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
with Orq(
|
|
596
|
+
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
|
597
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
598
|
+
) as orq:
|
|
599
|
+
|
|
600
|
+
res = orq.contacts.create(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
601
|
+
"premium",
|
|
602
|
+
"beta-user",
|
|
603
|
+
"enterprise",
|
|
604
|
+
], metadata={
|
|
605
|
+
"department": "Engineering",
|
|
606
|
+
"role": "Senior Developer",
|
|
607
|
+
"subscription_tier": "premium",
|
|
608
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
# Handle response
|
|
612
|
+
print(res)
|
|
613
|
+
|
|
614
|
+
```
|
|
615
|
+
<!-- End Retries [retries] -->
|
|
616
|
+
|
|
617
|
+
<!-- Start Error Handling [errors] -->
|
|
618
|
+
## Error Handling
|
|
619
|
+
|
|
620
|
+
[`OrqError`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/orqerror.py) is the base class for all HTTP error responses. It has the following properties:
|
|
621
|
+
|
|
622
|
+
| Property | Type | Description |
|
|
623
|
+
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
|
624
|
+
| `err.message` | `str` | Error message |
|
|
625
|
+
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
|
626
|
+
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
|
627
|
+
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
|
628
|
+
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
|
629
|
+
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/orq-ai/orq-python/blob/master/#error-classes). |
|
|
630
|
+
|
|
631
|
+
### Example
|
|
632
|
+
```python
|
|
633
|
+
from orq_ai_sdk import Orq, models
|
|
634
|
+
import os
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
with Orq(
|
|
638
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
639
|
+
) as orq:
|
|
640
|
+
res = None
|
|
641
|
+
try:
|
|
642
|
+
|
|
643
|
+
res = orq.evals.all(limit=10)
|
|
644
|
+
|
|
645
|
+
# Handle response
|
|
646
|
+
print(res)
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
except models.OrqError as e:
|
|
650
|
+
# The base class for HTTP error responses
|
|
651
|
+
print(e.message)
|
|
652
|
+
print(e.status_code)
|
|
653
|
+
print(e.body)
|
|
654
|
+
print(e.headers)
|
|
655
|
+
print(e.raw_response)
|
|
656
|
+
|
|
657
|
+
# Depending on the method different errors may be thrown
|
|
658
|
+
if isinstance(e, models.GetEvalsEvalsResponseBody):
|
|
659
|
+
print(e.data.message) # str
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Error Classes
|
|
663
|
+
**Primary error:**
|
|
664
|
+
* [`OrqError`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/orqerror.py): The base class for HTTP error responses.
|
|
665
|
+
|
|
666
|
+
<details><summary>Less common errors (35)</summary>
|
|
667
|
+
|
|
668
|
+
<br />
|
|
669
|
+
|
|
670
|
+
**Network errors:**
|
|
671
|
+
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
|
672
|
+
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
|
673
|
+
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
**Inherit from [`OrqError`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/orqerror.py)**:
|
|
677
|
+
* [`HonoAPIError`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/honoapierror.py): Applicable to 9 of 115 methods.*
|
|
678
|
+
* [`GenerateConversationNameConversationsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/generateconversationnameconversationsresponsebody.py): Conversation already has a display name. This endpoint only generates names for conversations with empty display names. Status code `400`. Applicable to 1 of 115 methods.*
|
|
679
|
+
* [`GetEvalsEvalsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/getevalsevalsresponsebody.py): Workspace ID is not found on the request. Status code `404`. Applicable to 1 of 115 methods.*
|
|
680
|
+
* [`CreateEvalEvalsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/createevalevalsresponsebody.py): Workspace ID is not found on the request. Status code `404`. Applicable to 1 of 115 methods.*
|
|
681
|
+
* [`UpdateEvalEvalsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updateevalevalsresponsebody.py): Workspace ID is not found on the request. Status code `404`. Applicable to 1 of 115 methods.*
|
|
682
|
+
* [`DeleteEvalResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/deleteevalresponsebody.py): Workspace ID is not found on the request. Status code `404`. Applicable to 1 of 115 methods.*
|
|
683
|
+
* [`InvokeEvalEvalsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/invokeevalevalsresponsebody.py): Workspace ID is not found on the request. Status code `404`. Applicable to 1 of 115 methods.*
|
|
684
|
+
* [`GetV2EvaluatorsIDVersionsEvaluatorsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/getv2evaluatorsidversionsevaluatorsresponsebody.py): Evaluator not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
685
|
+
* [`RetrieveIdentityIdentitiesResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/retrieveidentityidentitiesresponsebody.py): Identity not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
686
|
+
* [`UpdateIdentityIdentitiesResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updateidentityidentitiesresponsebody.py): Identity not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
687
|
+
* [`DeleteIdentityResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/deleteidentityresponsebody.py): Identity not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
688
|
+
* [`DeleteAgentResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/deleteagentresponsebody.py): Agent not found. The specified agent key does not exist in the workspace or has already been deleted. Status code `404`. Applicable to 1 of 115 methods.*
|
|
689
|
+
* [`RetrieveAgentRequestAgentsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/retrieveagentrequestagentsresponsebody.py): Agent not found. The specified agent key does not exist in the workspace or you do not have permission to access it. Status code `404`. Applicable to 1 of 115 methods.*
|
|
690
|
+
* [`UpdateAgentAgentsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updateagentagentsresponsebody.py): Agent not found. The specified agent key does not exist in the workspace or you do not have permission to modify it. Status code `404`. Applicable to 1 of 115 methods.*
|
|
691
|
+
* [`StreamRunAgentAgentsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/streamrunagentagentsresponsebody.py): Model not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
692
|
+
* [`StreamAgentAgentsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/streamagentagentsresponsebody.py): Agent not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
693
|
+
* [`GenerateConversationNameConversationsResponseResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/generateconversationnameconversationsresponseresponsebody.py): Conversation not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
694
|
+
* [`RetrieveConversationResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/retrieveconversationresponsebody.py): Conversation not found. The specified conversation ID does not exist in the workspace or you do not have permission to access it. Status code `404`. Applicable to 1 of 115 methods.*
|
|
695
|
+
* [`UpdateConversationConversationsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updateconversationconversationsresponsebody.py): Conversation not found. The specified conversation ID does not exist in the workspace or you do not have permission to modify it. Status code `404`. Applicable to 1 of 115 methods.*
|
|
696
|
+
* [`DeleteConversationResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/deleteconversationresponsebody.py): Conversation not found. The specified conversation ID does not exist in the workspace or has already been deleted. Status code `404`. Applicable to 1 of 115 methods.*
|
|
697
|
+
* [`UpdatePromptResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updatepromptresponsebody.py): Prompt not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
698
|
+
* [`DeletePromptResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/deletepromptresponsebody.py): Prompt not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
699
|
+
* [`GetPromptVersionPromptsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/getpromptversionpromptsresponsebody.py): Not Found - The prompt or prompt version does not exist. Status code `404`. Applicable to 1 of 115 methods.*
|
|
700
|
+
* [`UpdateToolToolsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/updatetooltoolsresponsebody.py): Tool not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
701
|
+
* [`GetV2ToolsToolIDVersionsToolsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/getv2toolstoolidversionstoolsresponsebody.py): Tool not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
702
|
+
* [`GetV2ToolsToolIDVersionsVersionIDToolsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/getv2toolstoolidversionsversionidtoolsresponsebody.py): Tool or version not found. Status code `404`. Applicable to 1 of 115 methods.*
|
|
703
|
+
* [`CreateModerationRouterModerationsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/createmoderationroutermoderationsresponsebody.py): Returns validation error. Status code `422`. Applicable to 1 of 115 methods.*
|
|
704
|
+
* [`CreateTranscriptionRouterAudioTranscriptionsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/createtranscriptionrouteraudiotranscriptionsresponsebody.py): Returns validation error. Status code `422`. Applicable to 1 of 115 methods.*
|
|
705
|
+
* [`CreateTranslationRouterAudioTranslationsResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/createtranslationrouteraudiotranslationsresponsebody.py): Returns validation error. Status code `422`. Applicable to 1 of 115 methods.*
|
|
706
|
+
* [`InvokeEvalEvalsResponseResponseBody`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/invokeevalevalsresponseresponsebody.py): Error running the evaluator. Status code `500`. Applicable to 1 of 115 methods.*
|
|
707
|
+
* [`ResponseValidationError`](https://github.com/orq-ai/orq-python/blob/master/./src/orq_ai_sdk/models/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
|
708
|
+
|
|
709
|
+
</details>
|
|
710
|
+
|
|
711
|
+
\* Check [the method documentation](https://github.com/orq-ai/orq-python/blob/master/#available-resources-and-operations) to see if the error is applicable.
|
|
712
|
+
<!-- End Error Handling [errors] -->
|
|
713
|
+
|
|
714
|
+
<!-- Start Server Selection [server] -->
|
|
715
|
+
## Server Selection
|
|
716
|
+
|
|
717
|
+
### Override Server URL Per-Client
|
|
718
|
+
|
|
719
|
+
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
|
720
|
+
```python
|
|
721
|
+
from orq_ai_sdk import Orq
|
|
722
|
+
import os
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
with Orq(
|
|
726
|
+
server_url="https://my.orq.ai",
|
|
727
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
728
|
+
) as orq:
|
|
729
|
+
|
|
730
|
+
res = orq.contacts.create(external_id="user_12345", display_name="Jane Smith", email="jane.smith@example.com", avatar_url="https://example.com/avatars/jane-smith.jpg", tags=[
|
|
731
|
+
"premium",
|
|
732
|
+
"beta-user",
|
|
733
|
+
"enterprise",
|
|
734
|
+
], metadata={
|
|
735
|
+
"department": "Engineering",
|
|
736
|
+
"role": "Senior Developer",
|
|
737
|
+
"subscription_tier": "premium",
|
|
738
|
+
"last_login": "2024-01-15T10:30:00Z",
|
|
739
|
+
})
|
|
740
|
+
|
|
741
|
+
# Handle response
|
|
742
|
+
print(res)
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
<!-- End Server Selection [server] -->
|
|
746
|
+
|
|
747
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
748
|
+
## Custom HTTP Client
|
|
749
|
+
|
|
750
|
+
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
|
|
751
|
+
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
|
|
752
|
+
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
|
|
753
|
+
|
|
754
|
+
For example, you could specify a header for every request that this sdk makes as follows:
|
|
755
|
+
```python
|
|
756
|
+
from orq_ai_sdk import Orq
|
|
757
|
+
import httpx
|
|
758
|
+
|
|
759
|
+
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
|
760
|
+
s = Orq(client=http_client)
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
or you could wrap the client with your own custom logic:
|
|
764
|
+
```python
|
|
765
|
+
from orq_ai_sdk import Orq
|
|
766
|
+
from orq_ai_sdk.httpclient import AsyncHttpClient
|
|
767
|
+
import httpx
|
|
768
|
+
|
|
769
|
+
class CustomClient(AsyncHttpClient):
|
|
770
|
+
client: AsyncHttpClient
|
|
771
|
+
|
|
772
|
+
def __init__(self, client: AsyncHttpClient):
|
|
773
|
+
self.client = client
|
|
774
|
+
|
|
775
|
+
async def send(
|
|
776
|
+
self,
|
|
777
|
+
request: httpx.Request,
|
|
778
|
+
*,
|
|
779
|
+
stream: bool = False,
|
|
780
|
+
auth: Union[
|
|
781
|
+
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
|
782
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
783
|
+
follow_redirects: Union[
|
|
784
|
+
bool, httpx._client.UseClientDefault
|
|
785
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
786
|
+
) -> httpx.Response:
|
|
787
|
+
request.headers["Client-Level-Header"] = "added by client"
|
|
788
|
+
|
|
789
|
+
return await self.client.send(
|
|
790
|
+
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
def build_request(
|
|
794
|
+
self,
|
|
795
|
+
method: str,
|
|
796
|
+
url: httpx._types.URLTypes,
|
|
797
|
+
*,
|
|
798
|
+
content: Optional[httpx._types.RequestContent] = None,
|
|
799
|
+
data: Optional[httpx._types.RequestData] = None,
|
|
800
|
+
files: Optional[httpx._types.RequestFiles] = None,
|
|
801
|
+
json: Optional[Any] = None,
|
|
802
|
+
params: Optional[httpx._types.QueryParamTypes] = None,
|
|
803
|
+
headers: Optional[httpx._types.HeaderTypes] = None,
|
|
804
|
+
cookies: Optional[httpx._types.CookieTypes] = None,
|
|
805
|
+
timeout: Union[
|
|
806
|
+
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
|
807
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
808
|
+
extensions: Optional[httpx._types.RequestExtensions] = None,
|
|
809
|
+
) -> httpx.Request:
|
|
810
|
+
return self.client.build_request(
|
|
811
|
+
method,
|
|
812
|
+
url,
|
|
813
|
+
content=content,
|
|
814
|
+
data=data,
|
|
815
|
+
files=files,
|
|
816
|
+
json=json,
|
|
817
|
+
params=params,
|
|
818
|
+
headers=headers,
|
|
819
|
+
cookies=cookies,
|
|
820
|
+
timeout=timeout,
|
|
821
|
+
extensions=extensions,
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
s = Orq(async_client=CustomClient(httpx.AsyncClient()))
|
|
825
|
+
```
|
|
826
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
827
|
+
|
|
828
|
+
<!-- Start Resource Management [resource-management] -->
|
|
829
|
+
## Resource Management
|
|
830
|
+
|
|
831
|
+
The `Orq` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
|
|
832
|
+
|
|
833
|
+
[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
|
|
834
|
+
|
|
835
|
+
```python
|
|
836
|
+
from orq_ai_sdk import Orq
|
|
837
|
+
import os
|
|
838
|
+
def main():
|
|
839
|
+
|
|
840
|
+
with Orq(
|
|
841
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
842
|
+
) as orq:
|
|
843
|
+
# Rest of application here...
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
# Or when using async:
|
|
847
|
+
async def amain():
|
|
848
|
+
|
|
849
|
+
async with Orq(
|
|
850
|
+
api_key=os.getenv("ORQ_API_KEY", ""),
|
|
851
|
+
) as orq:
|
|
852
|
+
# Rest of application here...
|
|
853
|
+
```
|
|
854
|
+
<!-- End Resource Management [resource-management] -->
|
|
855
|
+
|
|
856
|
+
<!-- Start Debugging [debug] -->
|
|
857
|
+
## Debugging
|
|
858
|
+
|
|
859
|
+
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
860
|
+
|
|
861
|
+
You can pass your own logger class directly into your SDK.
|
|
862
|
+
```python
|
|
863
|
+
from orq_ai_sdk import Orq
|
|
864
|
+
import logging
|
|
865
|
+
|
|
866
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
867
|
+
s = Orq(debug_logger=logging.getLogger("orq_ai_sdk"))
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
You can also enable a default debug logger by setting an environment variable `ORQ_DEBUG` to true.
|
|
871
|
+
<!-- End Debugging [debug] -->
|
|
872
|
+
|
|
873
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
874
|
+
|
|
875
|
+
# Development
|
|
876
|
+
|
|
877
|
+
## Maturity
|
|
878
|
+
|
|
879
|
+
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
|
880
|
+
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
|
881
|
+
looking for the latest version.
|
|
882
|
+
|
|
883
|
+
## Contributions
|
|
884
|
+
|
|
885
|
+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
|
886
|
+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
|
887
|
+
|
|
888
|
+
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=orq-ai-sdk&utm_campaign=python)
|