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