worqhat 3.10.0__py3-none-any.whl → 4.1.0__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 (92) hide show
  1. worqhat/__init__.py +8 -89
  2. worqhat/client.py +62 -0
  3. worqhat/exceptions.py +43 -0
  4. worqhat/http_client.py +171 -0
  5. worqhat/py.typed +1 -0
  6. worqhat/resources/__init__.py +5 -59
  7. worqhat/resources/database.py +293 -0
  8. worqhat/resources/flows.py +61 -409
  9. worqhat/resources/storage.py +41 -431
  10. worqhat-4.1.0.dist-info/METADATA +538 -0
  11. worqhat-4.1.0.dist-info/RECORD +13 -0
  12. {worqhat-3.10.0.dist-info → worqhat-4.1.0.dist-info}/WHEEL +2 -1
  13. worqhat-4.1.0.dist-info/top_level.txt +1 -0
  14. worqhat/_base_client.py +0 -1995
  15. worqhat/_client.py +0 -484
  16. worqhat/_compat.py +0 -219
  17. worqhat/_constants.py +0 -14
  18. worqhat/_exceptions.py +0 -108
  19. worqhat/_files.py +0 -123
  20. worqhat/_models.py +0 -835
  21. worqhat/_qs.py +0 -150
  22. worqhat/_resource.py +0 -43
  23. worqhat/_response.py +0 -830
  24. worqhat/_streaming.py +0 -333
  25. worqhat/_types.py +0 -260
  26. worqhat/_utils/__init__.py +0 -64
  27. worqhat/_utils/_compat.py +0 -45
  28. worqhat/_utils/_datetime_parse.py +0 -136
  29. worqhat/_utils/_logs.py +0 -25
  30. worqhat/_utils/_proxy.py +0 -65
  31. worqhat/_utils/_reflection.py +0 -42
  32. worqhat/_utils/_resources_proxy.py +0 -24
  33. worqhat/_utils/_streams.py +0 -12
  34. worqhat/_utils/_sync.py +0 -86
  35. worqhat/_utils/_transform.py +0 -457
  36. worqhat/_utils/_typing.py +0 -156
  37. worqhat/_utils/_utils.py +0 -421
  38. worqhat/_version.py +0 -4
  39. worqhat/lib/.keep +0 -4
  40. worqhat/resources/db/__init__.py +0 -33
  41. worqhat/resources/db/db.py +0 -1650
  42. worqhat/resources/db/tables.py +0 -389
  43. worqhat/resources/health.py +0 -143
  44. worqhat/types/__init__.py +0 -44
  45. worqhat/types/db/__init__.py +0 -10
  46. worqhat/types/db/table_get_row_count_params.py +0 -12
  47. worqhat/types/db/table_get_row_count_response.py +0 -15
  48. worqhat/types/db/table_list_params.py +0 -15
  49. worqhat/types/db/table_list_response.py +0 -26
  50. worqhat/types/db/table_retrieve_schema_params.py +0 -12
  51. worqhat/types/db/table_retrieve_schema_response.py +0 -29
  52. worqhat/types/db_cluster_params.py +0 -27
  53. worqhat/types/db_cluster_response.py +0 -44
  54. worqhat/types/db_delete_records_params.py +0 -19
  55. worqhat/types/db_delete_records_response.py +0 -18
  56. worqhat/types/db_detect_anomalies_params.py +0 -24
  57. worqhat/types/db_detect_anomalies_response.py +0 -50
  58. worqhat/types/db_execute_batch_params.py +0 -36
  59. worqhat/types/db_execute_batch_response.py +0 -27
  60. worqhat/types/db_execute_query_params.py +0 -24
  61. worqhat/types/db_execute_query_response.py +0 -21
  62. worqhat/types/db_find_similar_params.py +0 -31
  63. worqhat/types/db_find_similar_response.py +0 -30
  64. worqhat/types/db_hybrid_search_params.py +0 -32
  65. worqhat/types/db_hybrid_search_response.py +0 -48
  66. worqhat/types/db_insert_record_params.py +0 -19
  67. worqhat/types/db_insert_record_response.py +0 -15
  68. worqhat/types/db_process_nl_query_params.py +0 -19
  69. worqhat/types/db_process_nl_query_response.py +0 -18
  70. worqhat/types/db_recommend_params.py +0 -33
  71. worqhat/types/db_recommend_response.py +0 -36
  72. worqhat/types/db_semantic_search_params.py +0 -33
  73. worqhat/types/db_semantic_search_response.py +0 -36
  74. worqhat/types/db_update_records_params.py +0 -22
  75. worqhat/types/db_update_records_response.py +0 -18
  76. worqhat/types/flow_get_metrics_params.py +0 -25
  77. worqhat/types/flow_get_metrics_response.py +0 -55
  78. worqhat/types/flow_trigger_with_file_params.py +0 -17
  79. worqhat/types/flow_trigger_with_file_response.py +0 -18
  80. worqhat/types/flow_trigger_with_payload_params.py +0 -13
  81. worqhat/types/flow_trigger_with_payload_response.py +0 -20
  82. worqhat/types/get_server_info_response.py +0 -15
  83. worqhat/types/health_check_response.py +0 -33
  84. worqhat/types/storage_delete_file_by_id_response.py +0 -18
  85. worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
  86. worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
  87. worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
  88. worqhat/types/storage_upload_file_params.py +0 -17
  89. worqhat/types/storage_upload_file_response.py +0 -33
  90. worqhat-3.10.0.dist-info/METADATA +0 -432
  91. worqhat-3.10.0.dist-info/RECORD +0 -85
  92. worqhat-3.10.0.dist-info/licenses/LICENSE +0 -201
@@ -1,1650 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Dict, Union, Iterable
6
- from typing_extensions import Literal
7
-
8
- import httpx
9
-
10
- from .tables import (
11
- TablesResource,
12
- AsyncTablesResource,
13
- TablesResourceWithRawResponse,
14
- AsyncTablesResourceWithRawResponse,
15
- TablesResourceWithStreamingResponse,
16
- AsyncTablesResourceWithStreamingResponse,
17
- )
18
- from ...types import (
19
- db_cluster_params,
20
- db_recommend_params,
21
- db_find_similar_params,
22
- db_execute_batch_params,
23
- db_execute_query_params,
24
- db_hybrid_search_params,
25
- db_insert_record_params,
26
- db_delete_records_params,
27
- db_update_records_params,
28
- db_semantic_search_params,
29
- db_detect_anomalies_params,
30
- db_process_nl_query_params,
31
- )
32
- from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
33
- from ..._utils import maybe_transform, async_maybe_transform
34
- from ..._compat import cached_property
35
- from ..._resource import SyncAPIResource, AsyncAPIResource
36
- from ..._response import (
37
- to_raw_response_wrapper,
38
- to_streamed_response_wrapper,
39
- async_to_raw_response_wrapper,
40
- async_to_streamed_response_wrapper,
41
- )
42
- from ..._base_client import make_request_options
43
- from ...types.db_cluster_response import DBClusterResponse
44
- from ...types.db_recommend_response import DBRecommendResponse
45
- from ...types.db_find_similar_response import DBFindSimilarResponse
46
- from ...types.db_execute_batch_response import DBExecuteBatchResponse
47
- from ...types.db_execute_query_response import DBExecuteQueryResponse
48
- from ...types.db_hybrid_search_response import DBHybridSearchResponse
49
- from ...types.db_insert_record_response import DBInsertRecordResponse
50
- from ...types.db_delete_records_response import DBDeleteRecordsResponse
51
- from ...types.db_update_records_response import DBUpdateRecordsResponse
52
- from ...types.db_semantic_search_response import DBSemanticSearchResponse
53
- from ...types.db_detect_anomalies_response import DBDetectAnomaliesResponse
54
- from ...types.db_process_nl_query_response import DBProcessNlQueryResponse
55
-
56
- __all__ = ["DBResource", "AsyncDBResource"]
57
-
58
-
59
- class DBResource(SyncAPIResource):
60
- @cached_property
61
- def tables(self) -> TablesResource:
62
- return TablesResource(self._client)
63
-
64
- @cached_property
65
- def with_raw_response(self) -> DBResourceWithRawResponse:
66
- """
67
- This property can be used as a prefix for any HTTP method call to return
68
- the raw response object instead of the parsed content.
69
-
70
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
71
- """
72
- return DBResourceWithRawResponse(self)
73
-
74
- @cached_property
75
- def with_streaming_response(self) -> DBResourceWithStreamingResponse:
76
- """
77
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
78
-
79
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
80
- """
81
- return DBResourceWithStreamingResponse(self)
82
-
83
- def cluster(
84
- self,
85
- *,
86
- table: str,
87
- environment: Literal["development", "staging", "production"] | Omit = omit,
88
- generate_labels: bool | Omit = omit,
89
- max_clusters: float | Omit = omit,
90
- min_clusters: float | Omit = omit,
91
- num_clusters: float | Omit = omit,
92
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
93
- # The extra values given here take precedence over values defined on the client or passed to this method.
94
- extra_headers: Headers | None = None,
95
- extra_query: Query | None = None,
96
- extra_body: Body | None = None,
97
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
98
- ) -> DBClusterResponse:
99
- """
100
- Performs K-means clustering on vector embeddings to automatically group similar
101
- records. Supports auto-detection of optimal cluster count and AI-generated
102
- cluster labels. Returns cluster information including centroids, sample records,
103
- and quality metrics.
104
-
105
- Args:
106
- table: Table to cluster
107
-
108
- environment: Environment to cluster (development, staging, production)
109
-
110
- generate_labels: Whether to generate AI labels for clusters
111
-
112
- max_clusters: Maximum clusters for auto-detection
113
-
114
- min_clusters: Minimum clusters for auto-detection
115
-
116
- num_clusters: Number of clusters (auto-detected if not provided)
117
-
118
- extra_headers: Send extra headers
119
-
120
- extra_query: Add additional query parameters to the request
121
-
122
- extra_body: Add additional JSON properties to the request
123
-
124
- timeout: Override the client-level default timeout for this request, in seconds
125
- """
126
- return self._post(
127
- "/db/cluster",
128
- body=maybe_transform(
129
- {
130
- "table": table,
131
- "environment": environment,
132
- "generate_labels": generate_labels,
133
- "max_clusters": max_clusters,
134
- "min_clusters": min_clusters,
135
- "num_clusters": num_clusters,
136
- },
137
- db_cluster_params.DBClusterParams,
138
- ),
139
- options=make_request_options(
140
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
141
- ),
142
- cast_to=DBClusterResponse,
143
- )
144
-
145
- def delete_records(
146
- self,
147
- *,
148
- table: str,
149
- where: Dict[str, object],
150
- environment: Literal["development", "staging", "production"] | Omit = omit,
151
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
152
- # The extra values given here take precedence over values defined on the client or passed to this method.
153
- extra_headers: Headers | None = None,
154
- extra_query: Query | None = None,
155
- extra_body: Body | None = None,
156
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
157
- ) -> DBDeleteRecordsResponse:
158
- """
159
- Deletes records from the specified table that match the where conditions.
160
- Organization ID filtering is automatically applied for multi-tenant security.
161
-
162
- Args:
163
- table: Table name to delete from
164
-
165
- where: Where conditions
166
-
167
- environment: Environment to delete from (development, staging, production)
168
-
169
- extra_headers: Send extra headers
170
-
171
- extra_query: Add additional query parameters to the request
172
-
173
- extra_body: Add additional JSON properties to the request
174
-
175
- timeout: Override the client-level default timeout for this request, in seconds
176
- """
177
- return self._delete(
178
- "/db/delete",
179
- body=maybe_transform(
180
- {
181
- "table": table,
182
- "where": where,
183
- "environment": environment,
184
- },
185
- db_delete_records_params.DBDeleteRecordsParams,
186
- ),
187
- options=make_request_options(
188
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
189
- ),
190
- cast_to=DBDeleteRecordsResponse,
191
- )
192
-
193
- def detect_anomalies(
194
- self,
195
- *,
196
- table: str,
197
- environment: Literal["development", "staging", "production"] | Omit = omit,
198
- k: float | Omit = omit,
199
- limit: float | Omit = omit,
200
- threshold: float | Omit = omit,
201
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
202
- # The extra values given here take precedence over values defined on the client or passed to this method.
203
- extra_headers: Headers | None = None,
204
- extra_query: Query | None = None,
205
- extra_body: Body | None = None,
206
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
207
- ) -> DBDetectAnomaliesResponse:
208
- """
209
- Identifies anomalous or outlier records using K-nearest neighbors analysis on
210
- vector embeddings. Useful for fraud detection, data quality checks, and
211
- identifying unusual patterns. Returns anomaly scores and nearest neighbors for
212
- each detected anomaly.
213
-
214
- Args:
215
- table: Table to analyze for anomalies
216
-
217
- environment: Environment to analyze (development, staging, production)
218
-
219
- k: Number of nearest neighbors to consider
220
-
221
- limit: Maximum number of anomalies to return
222
-
223
- threshold: Minimum anomaly score threshold
224
-
225
- extra_headers: Send extra headers
226
-
227
- extra_query: Add additional query parameters to the request
228
-
229
- extra_body: Add additional JSON properties to the request
230
-
231
- timeout: Override the client-level default timeout for this request, in seconds
232
- """
233
- return self._post(
234
- "/db/detect-anomalies",
235
- body=maybe_transform(
236
- {
237
- "table": table,
238
- "environment": environment,
239
- "k": k,
240
- "limit": limit,
241
- "threshold": threshold,
242
- },
243
- db_detect_anomalies_params.DBDetectAnomaliesParams,
244
- ),
245
- options=make_request_options(
246
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
247
- ),
248
- cast_to=DBDetectAnomaliesResponse,
249
- )
250
-
251
- def execute_batch(
252
- self,
253
- *,
254
- operations: Iterable[db_execute_batch_params.Operation],
255
- environment: Literal["development", "staging", "production"] | Omit = omit,
256
- transactional: bool | Omit = omit,
257
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
258
- # The extra values given here take precedence over values defined on the client or passed to this method.
259
- extra_headers: Headers | None = None,
260
- extra_query: Query | None = None,
261
- extra_body: Body | None = None,
262
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
263
- ) -> DBExecuteBatchResponse:
264
- """
265
- Executes multiple database operations (queries, inserts, updates, deletes) in a
266
- single transaction. If transactional is true, all operations will be rolled back
267
- if any operation fails.
268
-
269
- Args:
270
- operations: Array of database operations to execute
271
-
272
- environment: Environment to execute operations in
273
-
274
- transactional: Whether to execute all operations in a single transaction
275
-
276
- extra_headers: Send extra headers
277
-
278
- extra_query: Add additional query parameters to the request
279
-
280
- extra_body: Add additional JSON properties to the request
281
-
282
- timeout: Override the client-level default timeout for this request, in seconds
283
- """
284
- return self._post(
285
- "/db/batch",
286
- body=maybe_transform(
287
- {
288
- "operations": operations,
289
- "environment": environment,
290
- "transactional": transactional,
291
- },
292
- db_execute_batch_params.DBExecuteBatchParams,
293
- ),
294
- options=make_request_options(
295
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
296
- ),
297
- cast_to=DBExecuteBatchResponse,
298
- )
299
-
300
- def execute_query(
301
- self,
302
- *,
303
- query: str,
304
- environment: Literal["development", "staging", "production"] | Omit = omit,
305
- params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
306
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
307
- # The extra values given here take precedence over values defined on the client or passed to this method.
308
- extra_headers: Headers | None = None,
309
- extra_query: Query | None = None,
310
- extra_body: Body | None = None,
311
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
312
- ) -> DBExecuteQueryResponse:
313
- """Executes a raw SQL query directly against the database.
314
-
315
- Supports both named
316
- parameters ({param}) and positional parameters ($1, $2). Provides security
317
- guardrails to prevent destructive operations.
318
-
319
- Args:
320
- query: SQL query to execute. Supports both named parameters ({param}) and positional
321
- parameters ($1, $2)
322
-
323
- environment: Environment to query (development, staging, production)
324
-
325
- params: Named parameters for queries with {param} syntax
326
-
327
- extra_headers: Send extra headers
328
-
329
- extra_query: Add additional query parameters to the request
330
-
331
- extra_body: Add additional JSON properties to the request
332
-
333
- timeout: Override the client-level default timeout for this request, in seconds
334
- """
335
- return self._post(
336
- "/db/query",
337
- body=maybe_transform(
338
- {
339
- "query": query,
340
- "environment": environment,
341
- "params": params,
342
- },
343
- db_execute_query_params.DBExecuteQueryParams,
344
- ),
345
- options=make_request_options(
346
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
347
- ),
348
- cast_to=DBExecuteQueryResponse,
349
- )
350
-
351
- def find_similar(
352
- self,
353
- *,
354
- record_id: Union[str, float],
355
- table: str,
356
- environment: Literal["development", "staging", "production"] | Omit = omit,
357
- exclude_self: bool | Omit = omit,
358
- limit: float | Omit = omit,
359
- target_table: str | Omit = omit,
360
- threshold: float | Omit = omit,
361
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
362
- # The extra values given here take precedence over values defined on the client or passed to this method.
363
- extra_headers: Headers | None = None,
364
- extra_query: Query | None = None,
365
- extra_body: Body | None = None,
366
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
367
- ) -> DBFindSimilarResponse:
368
- """
369
- Finds records similar to a specific existing record using vector embeddings.
370
- Useful for "More like this" functionality and cross-table similarity search.
371
- Returns similarity scores and supports excluding the source record.
372
-
373
- Args:
374
- record_id: ID of the source record
375
-
376
- table: Table containing the source record
377
-
378
- environment: Environment to search in (development, staging, production)
379
-
380
- exclude_self: Whether to exclude the source record from results
381
-
382
- limit: Maximum number of similar records to return
383
-
384
- target_table: Different table to search in (optional)
385
-
386
- threshold: Minimum similarity score threshold
387
-
388
- extra_headers: Send extra headers
389
-
390
- extra_query: Add additional query parameters to the request
391
-
392
- extra_body: Add additional JSON properties to the request
393
-
394
- timeout: Override the client-level default timeout for this request, in seconds
395
- """
396
- return self._post(
397
- "/db/find-similar",
398
- body=maybe_transform(
399
- {
400
- "record_id": record_id,
401
- "table": table,
402
- "environment": environment,
403
- "exclude_self": exclude_self,
404
- "limit": limit,
405
- "target_table": target_table,
406
- "threshold": threshold,
407
- },
408
- db_find_similar_params.DBFindSimilarParams,
409
- ),
410
- options=make_request_options(
411
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
412
- ),
413
- cast_to=DBFindSimilarResponse,
414
- )
415
-
416
- def hybrid_search(
417
- self,
418
- *,
419
- query: str,
420
- table: str,
421
- environment: Literal["development", "staging", "production"] | Omit = omit,
422
- keyword_weight: float | Omit = omit,
423
- limit: float | Omit = omit,
424
- semantic_weight: float | Omit = omit,
425
- text_columns: SequenceNotStr[str] | Omit = omit,
426
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
427
- # The extra values given here take precedence over values defined on the client or passed to this method.
428
- extra_headers: Headers | None = None,
429
- extra_query: Query | None = None,
430
- extra_body: Body | None = None,
431
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
432
- ) -> DBHybridSearchResponse:
433
- """Combines semantic search using vector embeddings with traditional keyword
434
- search.
435
-
436
- Provides weighted scoring between semantic similarity and keyword
437
- matching. Ideal for queries that need both contextual understanding and exact
438
- term matching.
439
-
440
- Args:
441
- query: Search query combining natural language and keywords
442
-
443
- table: Table to search in
444
-
445
- environment: Environment to search in (development, staging, production)
446
-
447
- keyword_weight: Weight for keyword matching score
448
-
449
- limit: Maximum number of results to return
450
-
451
- semantic_weight: Weight for semantic similarity score
452
-
453
- text_columns: Columns to include in keyword search
454
-
455
- extra_headers: Send extra headers
456
-
457
- extra_query: Add additional query parameters to the request
458
-
459
- extra_body: Add additional JSON properties to the request
460
-
461
- timeout: Override the client-level default timeout for this request, in seconds
462
- """
463
- return self._post(
464
- "/db/hybrid-search",
465
- body=maybe_transform(
466
- {
467
- "query": query,
468
- "table": table,
469
- "environment": environment,
470
- "keyword_weight": keyword_weight,
471
- "limit": limit,
472
- "semantic_weight": semantic_weight,
473
- "text_columns": text_columns,
474
- },
475
- db_hybrid_search_params.DBHybridSearchParams,
476
- ),
477
- options=make_request_options(
478
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
479
- ),
480
- cast_to=DBHybridSearchResponse,
481
- )
482
-
483
- def insert_record(
484
- self,
485
- *,
486
- data: Dict[str, object],
487
- table: str,
488
- environment: Literal["development", "staging", "production"] | Omit = omit,
489
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
490
- # The extra values given here take precedence over values defined on the client or passed to this method.
491
- extra_headers: Headers | None = None,
492
- extra_query: Query | None = None,
493
- extra_body: Body | None = None,
494
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
495
- ) -> DBInsertRecordResponse:
496
- """Inserts a new record into the specified table.
497
-
498
- Organization ID is automatically
499
- added for multi-tenant security.
500
-
501
- Args:
502
- data: Data to insert
503
-
504
- table: Table name to insert into
505
-
506
- environment: Environment to insert into (development, staging, production)
507
-
508
- extra_headers: Send extra headers
509
-
510
- extra_query: Add additional query parameters to the request
511
-
512
- extra_body: Add additional JSON properties to the request
513
-
514
- timeout: Override the client-level default timeout for this request, in seconds
515
- """
516
- return self._post(
517
- "/db/insert",
518
- body=maybe_transform(
519
- {
520
- "data": data,
521
- "table": table,
522
- "environment": environment,
523
- },
524
- db_insert_record_params.DBInsertRecordParams,
525
- ),
526
- options=make_request_options(
527
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
528
- ),
529
- cast_to=DBInsertRecordResponse,
530
- )
531
-
532
- def process_nl_query(
533
- self,
534
- *,
535
- question: str,
536
- context: Dict[str, object] | Omit = omit,
537
- environment: Literal["development", "staging", "production"] | Omit = omit,
538
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
539
- # The extra values given here take precedence over values defined on the client or passed to this method.
540
- extra_headers: Headers | None = None,
541
- extra_query: Query | None = None,
542
- extra_body: Body | None = None,
543
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
544
- ) -> DBProcessNlQueryResponse:
545
- """
546
- Converts a natural language question into a SQL query and executes it.
547
- Organization ID filtering is automatically applied for multi-tenant security.
548
-
549
- Args:
550
- question: Natural language question
551
-
552
- context: Optional context for the query
553
-
554
- environment: Environment to query (development, staging, production)
555
-
556
- extra_headers: Send extra headers
557
-
558
- extra_query: Add additional query parameters to the request
559
-
560
- extra_body: Add additional JSON properties to the request
561
-
562
- timeout: Override the client-level default timeout for this request, in seconds
563
- """
564
- return self._post(
565
- "/db/nl-query",
566
- body=maybe_transform(
567
- {
568
- "question": question,
569
- "context": context,
570
- "environment": environment,
571
- },
572
- db_process_nl_query_params.DBProcessNlQueryParams,
573
- ),
574
- options=make_request_options(
575
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
576
- ),
577
- cast_to=DBProcessNlQueryResponse,
578
- )
579
-
580
- def recommend(
581
- self,
582
- *,
583
- table: str,
584
- environment: Literal["development", "staging", "production"] | Omit = omit,
585
- exclude_ids: SequenceNotStr[str] | Omit = omit,
586
- limit: float | Omit = omit,
587
- record_id: Union[str, float] | Omit = omit,
588
- strategy: Literal["similar", "diverse", "popular"] | Omit = omit,
589
- user_history: SequenceNotStr[str] | Omit = omit,
590
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
591
- # The extra values given here take precedence over values defined on the client or passed to this method.
592
- extra_headers: Headers | None = None,
593
- extra_query: Query | None = None,
594
- extra_body: Body | None = None,
595
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
596
- ) -> DBRecommendResponse:
597
- """
598
- Generates item recommendations using vector embeddings and collaborative
599
- filtering. Supports multiple recommendation strategies including similar items,
600
- diverse recommendations, and user history-based recommendations.
601
-
602
- Args:
603
- table: Table to generate recommendations from
604
-
605
- environment: Environment to search in (development, staging, production)
606
-
607
- exclude_ids: Record IDs to exclude from recommendations
608
-
609
- limit: Maximum number of recommendations to return
610
-
611
- record_id: Source item ID for item-to-item recommendations
612
-
613
- strategy: Recommendation strategy to use
614
-
615
- user_history: Array of record IDs the user has interacted with
616
-
617
- extra_headers: Send extra headers
618
-
619
- extra_query: Add additional query parameters to the request
620
-
621
- extra_body: Add additional JSON properties to the request
622
-
623
- timeout: Override the client-level default timeout for this request, in seconds
624
- """
625
- return self._post(
626
- "/db/recommend",
627
- body=maybe_transform(
628
- {
629
- "table": table,
630
- "environment": environment,
631
- "exclude_ids": exclude_ids,
632
- "limit": limit,
633
- "record_id": record_id,
634
- "strategy": strategy,
635
- "user_history": user_history,
636
- },
637
- db_recommend_params.DBRecommendParams,
638
- ),
639
- options=make_request_options(
640
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
641
- ),
642
- cast_to=DBRecommendResponse,
643
- )
644
-
645
- def semantic_search(
646
- self,
647
- *,
648
- query: str,
649
- environment: Literal["development", "staging", "production"] | Omit = omit,
650
- filters: Dict[str, object] | Omit = omit,
651
- limit: float | Omit = omit,
652
- table: str | Omit = omit,
653
- tables: SequenceNotStr[str] | Omit = omit,
654
- threshold: float | Omit = omit,
655
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
656
- # The extra values given here take precedence over values defined on the client or passed to this method.
657
- extra_headers: Headers | None = None,
658
- extra_query: Query | None = None,
659
- extra_body: Body | None = None,
660
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
661
- ) -> DBSemanticSearchResponse:
662
- """
663
- Performs semantic search across database tables using vector embeddings.
664
- Supports both single table and cross-table searches with configurable similarity
665
- thresholds. Returns records with similarity scores and metadata about matched
666
- fields.
667
-
668
- Args:
669
- query: Natural language search query
670
-
671
- environment: Environment to search in (development, staging, production)
672
-
673
- filters: Additional WHERE conditions to apply
674
-
675
- limit: Maximum number of results to return
676
-
677
- table: Single table to search in (optional if tables is provided)
678
-
679
- tables: Multiple tables to search across (optional if table is provided)
680
-
681
- threshold: Minimum similarity score threshold
682
-
683
- extra_headers: Send extra headers
684
-
685
- extra_query: Add additional query parameters to the request
686
-
687
- extra_body: Add additional JSON properties to the request
688
-
689
- timeout: Override the client-level default timeout for this request, in seconds
690
- """
691
- return self._post(
692
- "/db/semantic-search",
693
- body=maybe_transform(
694
- {
695
- "query": query,
696
- "environment": environment,
697
- "filters": filters,
698
- "limit": limit,
699
- "table": table,
700
- "tables": tables,
701
- "threshold": threshold,
702
- },
703
- db_semantic_search_params.DBSemanticSearchParams,
704
- ),
705
- options=make_request_options(
706
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
707
- ),
708
- cast_to=DBSemanticSearchResponse,
709
- )
710
-
711
- def update_records(
712
- self,
713
- *,
714
- data: Dict[str, object],
715
- table: str,
716
- where: Dict[str, object],
717
- environment: Literal["development", "staging", "production"] | Omit = omit,
718
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
719
- # The extra values given here take precedence over values defined on the client or passed to this method.
720
- extra_headers: Headers | None = None,
721
- extra_query: Query | None = None,
722
- extra_body: Body | None = None,
723
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
724
- ) -> DBUpdateRecordsResponse:
725
- """
726
- Updates records in the specified table that match the where conditions.
727
- Organization ID filtering is automatically applied for multi-tenant security.
728
-
729
- Args:
730
- data: Data to update
731
-
732
- table: Table name to update
733
-
734
- where: Where conditions
735
-
736
- environment: Environment to update in (development, staging, production)
737
-
738
- extra_headers: Send extra headers
739
-
740
- extra_query: Add additional query parameters to the request
741
-
742
- extra_body: Add additional JSON properties to the request
743
-
744
- timeout: Override the client-level default timeout for this request, in seconds
745
- """
746
- return self._put(
747
- "/db/update",
748
- body=maybe_transform(
749
- {
750
- "data": data,
751
- "table": table,
752
- "where": where,
753
- "environment": environment,
754
- },
755
- db_update_records_params.DBUpdateRecordsParams,
756
- ),
757
- options=make_request_options(
758
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
759
- ),
760
- cast_to=DBUpdateRecordsResponse,
761
- )
762
-
763
-
764
- class AsyncDBResource(AsyncAPIResource):
765
- @cached_property
766
- def tables(self) -> AsyncTablesResource:
767
- return AsyncTablesResource(self._client)
768
-
769
- @cached_property
770
- def with_raw_response(self) -> AsyncDBResourceWithRawResponse:
771
- """
772
- This property can be used as a prefix for any HTTP method call to return
773
- the raw response object instead of the parsed content.
774
-
775
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
776
- """
777
- return AsyncDBResourceWithRawResponse(self)
778
-
779
- @cached_property
780
- def with_streaming_response(self) -> AsyncDBResourceWithStreamingResponse:
781
- """
782
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
783
-
784
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
785
- """
786
- return AsyncDBResourceWithStreamingResponse(self)
787
-
788
- async def cluster(
789
- self,
790
- *,
791
- table: str,
792
- environment: Literal["development", "staging", "production"] | Omit = omit,
793
- generate_labels: bool | Omit = omit,
794
- max_clusters: float | Omit = omit,
795
- min_clusters: float | Omit = omit,
796
- num_clusters: float | Omit = omit,
797
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
798
- # The extra values given here take precedence over values defined on the client or passed to this method.
799
- extra_headers: Headers | None = None,
800
- extra_query: Query | None = None,
801
- extra_body: Body | None = None,
802
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
803
- ) -> DBClusterResponse:
804
- """
805
- Performs K-means clustering on vector embeddings to automatically group similar
806
- records. Supports auto-detection of optimal cluster count and AI-generated
807
- cluster labels. Returns cluster information including centroids, sample records,
808
- and quality metrics.
809
-
810
- Args:
811
- table: Table to cluster
812
-
813
- environment: Environment to cluster (development, staging, production)
814
-
815
- generate_labels: Whether to generate AI labels for clusters
816
-
817
- max_clusters: Maximum clusters for auto-detection
818
-
819
- min_clusters: Minimum clusters for auto-detection
820
-
821
- num_clusters: Number of clusters (auto-detected if not provided)
822
-
823
- extra_headers: Send extra headers
824
-
825
- extra_query: Add additional query parameters to the request
826
-
827
- extra_body: Add additional JSON properties to the request
828
-
829
- timeout: Override the client-level default timeout for this request, in seconds
830
- """
831
- return await self._post(
832
- "/db/cluster",
833
- body=await async_maybe_transform(
834
- {
835
- "table": table,
836
- "environment": environment,
837
- "generate_labels": generate_labels,
838
- "max_clusters": max_clusters,
839
- "min_clusters": min_clusters,
840
- "num_clusters": num_clusters,
841
- },
842
- db_cluster_params.DBClusterParams,
843
- ),
844
- options=make_request_options(
845
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
846
- ),
847
- cast_to=DBClusterResponse,
848
- )
849
-
850
- async def delete_records(
851
- self,
852
- *,
853
- table: str,
854
- where: Dict[str, object],
855
- environment: Literal["development", "staging", "production"] | Omit = omit,
856
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
857
- # The extra values given here take precedence over values defined on the client or passed to this method.
858
- extra_headers: Headers | None = None,
859
- extra_query: Query | None = None,
860
- extra_body: Body | None = None,
861
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
862
- ) -> DBDeleteRecordsResponse:
863
- """
864
- Deletes records from the specified table that match the where conditions.
865
- Organization ID filtering is automatically applied for multi-tenant security.
866
-
867
- Args:
868
- table: Table name to delete from
869
-
870
- where: Where conditions
871
-
872
- environment: Environment to delete from (development, staging, production)
873
-
874
- extra_headers: Send extra headers
875
-
876
- extra_query: Add additional query parameters to the request
877
-
878
- extra_body: Add additional JSON properties to the request
879
-
880
- timeout: Override the client-level default timeout for this request, in seconds
881
- """
882
- return await self._delete(
883
- "/db/delete",
884
- body=await async_maybe_transform(
885
- {
886
- "table": table,
887
- "where": where,
888
- "environment": environment,
889
- },
890
- db_delete_records_params.DBDeleteRecordsParams,
891
- ),
892
- options=make_request_options(
893
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
894
- ),
895
- cast_to=DBDeleteRecordsResponse,
896
- )
897
-
898
- async def detect_anomalies(
899
- self,
900
- *,
901
- table: str,
902
- environment: Literal["development", "staging", "production"] | Omit = omit,
903
- k: float | Omit = omit,
904
- limit: float | Omit = omit,
905
- threshold: float | Omit = omit,
906
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
907
- # The extra values given here take precedence over values defined on the client or passed to this method.
908
- extra_headers: Headers | None = None,
909
- extra_query: Query | None = None,
910
- extra_body: Body | None = None,
911
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
912
- ) -> DBDetectAnomaliesResponse:
913
- """
914
- Identifies anomalous or outlier records using K-nearest neighbors analysis on
915
- vector embeddings. Useful for fraud detection, data quality checks, and
916
- identifying unusual patterns. Returns anomaly scores and nearest neighbors for
917
- each detected anomaly.
918
-
919
- Args:
920
- table: Table to analyze for anomalies
921
-
922
- environment: Environment to analyze (development, staging, production)
923
-
924
- k: Number of nearest neighbors to consider
925
-
926
- limit: Maximum number of anomalies to return
927
-
928
- threshold: Minimum anomaly score threshold
929
-
930
- extra_headers: Send extra headers
931
-
932
- extra_query: Add additional query parameters to the request
933
-
934
- extra_body: Add additional JSON properties to the request
935
-
936
- timeout: Override the client-level default timeout for this request, in seconds
937
- """
938
- return await self._post(
939
- "/db/detect-anomalies",
940
- body=await async_maybe_transform(
941
- {
942
- "table": table,
943
- "environment": environment,
944
- "k": k,
945
- "limit": limit,
946
- "threshold": threshold,
947
- },
948
- db_detect_anomalies_params.DBDetectAnomaliesParams,
949
- ),
950
- options=make_request_options(
951
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
952
- ),
953
- cast_to=DBDetectAnomaliesResponse,
954
- )
955
-
956
- async def execute_batch(
957
- self,
958
- *,
959
- operations: Iterable[db_execute_batch_params.Operation],
960
- environment: Literal["development", "staging", "production"] | Omit = omit,
961
- transactional: bool | Omit = omit,
962
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
963
- # The extra values given here take precedence over values defined on the client or passed to this method.
964
- extra_headers: Headers | None = None,
965
- extra_query: Query | None = None,
966
- extra_body: Body | None = None,
967
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
968
- ) -> DBExecuteBatchResponse:
969
- """
970
- Executes multiple database operations (queries, inserts, updates, deletes) in a
971
- single transaction. If transactional is true, all operations will be rolled back
972
- if any operation fails.
973
-
974
- Args:
975
- operations: Array of database operations to execute
976
-
977
- environment: Environment to execute operations in
978
-
979
- transactional: Whether to execute all operations in a single transaction
980
-
981
- extra_headers: Send extra headers
982
-
983
- extra_query: Add additional query parameters to the request
984
-
985
- extra_body: Add additional JSON properties to the request
986
-
987
- timeout: Override the client-level default timeout for this request, in seconds
988
- """
989
- return await self._post(
990
- "/db/batch",
991
- body=await async_maybe_transform(
992
- {
993
- "operations": operations,
994
- "environment": environment,
995
- "transactional": transactional,
996
- },
997
- db_execute_batch_params.DBExecuteBatchParams,
998
- ),
999
- options=make_request_options(
1000
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1001
- ),
1002
- cast_to=DBExecuteBatchResponse,
1003
- )
1004
-
1005
- async def execute_query(
1006
- self,
1007
- *,
1008
- query: str,
1009
- environment: Literal["development", "staging", "production"] | Omit = omit,
1010
- params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
1011
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1012
- # The extra values given here take precedence over values defined on the client or passed to this method.
1013
- extra_headers: Headers | None = None,
1014
- extra_query: Query | None = None,
1015
- extra_body: Body | None = None,
1016
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1017
- ) -> DBExecuteQueryResponse:
1018
- """Executes a raw SQL query directly against the database.
1019
-
1020
- Supports both named
1021
- parameters ({param}) and positional parameters ($1, $2). Provides security
1022
- guardrails to prevent destructive operations.
1023
-
1024
- Args:
1025
- query: SQL query to execute. Supports both named parameters ({param}) and positional
1026
- parameters ($1, $2)
1027
-
1028
- environment: Environment to query (development, staging, production)
1029
-
1030
- params: Named parameters for queries with {param} syntax
1031
-
1032
- extra_headers: Send extra headers
1033
-
1034
- extra_query: Add additional query parameters to the request
1035
-
1036
- extra_body: Add additional JSON properties to the request
1037
-
1038
- timeout: Override the client-level default timeout for this request, in seconds
1039
- """
1040
- return await self._post(
1041
- "/db/query",
1042
- body=await async_maybe_transform(
1043
- {
1044
- "query": query,
1045
- "environment": environment,
1046
- "params": params,
1047
- },
1048
- db_execute_query_params.DBExecuteQueryParams,
1049
- ),
1050
- options=make_request_options(
1051
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1052
- ),
1053
- cast_to=DBExecuteQueryResponse,
1054
- )
1055
-
1056
- async def find_similar(
1057
- self,
1058
- *,
1059
- record_id: Union[str, float],
1060
- table: str,
1061
- environment: Literal["development", "staging", "production"] | Omit = omit,
1062
- exclude_self: bool | Omit = omit,
1063
- limit: float | Omit = omit,
1064
- target_table: str | Omit = omit,
1065
- threshold: float | Omit = omit,
1066
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1067
- # The extra values given here take precedence over values defined on the client or passed to this method.
1068
- extra_headers: Headers | None = None,
1069
- extra_query: Query | None = None,
1070
- extra_body: Body | None = None,
1071
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1072
- ) -> DBFindSimilarResponse:
1073
- """
1074
- Finds records similar to a specific existing record using vector embeddings.
1075
- Useful for "More like this" functionality and cross-table similarity search.
1076
- Returns similarity scores and supports excluding the source record.
1077
-
1078
- Args:
1079
- record_id: ID of the source record
1080
-
1081
- table: Table containing the source record
1082
-
1083
- environment: Environment to search in (development, staging, production)
1084
-
1085
- exclude_self: Whether to exclude the source record from results
1086
-
1087
- limit: Maximum number of similar records to return
1088
-
1089
- target_table: Different table to search in (optional)
1090
-
1091
- threshold: Minimum similarity score threshold
1092
-
1093
- extra_headers: Send extra headers
1094
-
1095
- extra_query: Add additional query parameters to the request
1096
-
1097
- extra_body: Add additional JSON properties to the request
1098
-
1099
- timeout: Override the client-level default timeout for this request, in seconds
1100
- """
1101
- return await self._post(
1102
- "/db/find-similar",
1103
- body=await async_maybe_transform(
1104
- {
1105
- "record_id": record_id,
1106
- "table": table,
1107
- "environment": environment,
1108
- "exclude_self": exclude_self,
1109
- "limit": limit,
1110
- "target_table": target_table,
1111
- "threshold": threshold,
1112
- },
1113
- db_find_similar_params.DBFindSimilarParams,
1114
- ),
1115
- options=make_request_options(
1116
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1117
- ),
1118
- cast_to=DBFindSimilarResponse,
1119
- )
1120
-
1121
- async def hybrid_search(
1122
- self,
1123
- *,
1124
- query: str,
1125
- table: str,
1126
- environment: Literal["development", "staging", "production"] | Omit = omit,
1127
- keyword_weight: float | Omit = omit,
1128
- limit: float | Omit = omit,
1129
- semantic_weight: float | Omit = omit,
1130
- text_columns: SequenceNotStr[str] | Omit = omit,
1131
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1132
- # The extra values given here take precedence over values defined on the client or passed to this method.
1133
- extra_headers: Headers | None = None,
1134
- extra_query: Query | None = None,
1135
- extra_body: Body | None = None,
1136
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1137
- ) -> DBHybridSearchResponse:
1138
- """Combines semantic search using vector embeddings with traditional keyword
1139
- search.
1140
-
1141
- Provides weighted scoring between semantic similarity and keyword
1142
- matching. Ideal for queries that need both contextual understanding and exact
1143
- term matching.
1144
-
1145
- Args:
1146
- query: Search query combining natural language and keywords
1147
-
1148
- table: Table to search in
1149
-
1150
- environment: Environment to search in (development, staging, production)
1151
-
1152
- keyword_weight: Weight for keyword matching score
1153
-
1154
- limit: Maximum number of results to return
1155
-
1156
- semantic_weight: Weight for semantic similarity score
1157
-
1158
- text_columns: Columns to include in keyword search
1159
-
1160
- extra_headers: Send extra headers
1161
-
1162
- extra_query: Add additional query parameters to the request
1163
-
1164
- extra_body: Add additional JSON properties to the request
1165
-
1166
- timeout: Override the client-level default timeout for this request, in seconds
1167
- """
1168
- return await self._post(
1169
- "/db/hybrid-search",
1170
- body=await async_maybe_transform(
1171
- {
1172
- "query": query,
1173
- "table": table,
1174
- "environment": environment,
1175
- "keyword_weight": keyword_weight,
1176
- "limit": limit,
1177
- "semantic_weight": semantic_weight,
1178
- "text_columns": text_columns,
1179
- },
1180
- db_hybrid_search_params.DBHybridSearchParams,
1181
- ),
1182
- options=make_request_options(
1183
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1184
- ),
1185
- cast_to=DBHybridSearchResponse,
1186
- )
1187
-
1188
- async def insert_record(
1189
- self,
1190
- *,
1191
- data: Dict[str, object],
1192
- table: str,
1193
- environment: Literal["development", "staging", "production"] | Omit = omit,
1194
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1195
- # The extra values given here take precedence over values defined on the client or passed to this method.
1196
- extra_headers: Headers | None = None,
1197
- extra_query: Query | None = None,
1198
- extra_body: Body | None = None,
1199
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1200
- ) -> DBInsertRecordResponse:
1201
- """Inserts a new record into the specified table.
1202
-
1203
- Organization ID is automatically
1204
- added for multi-tenant security.
1205
-
1206
- Args:
1207
- data: Data to insert
1208
-
1209
- table: Table name to insert into
1210
-
1211
- environment: Environment to insert into (development, staging, production)
1212
-
1213
- extra_headers: Send extra headers
1214
-
1215
- extra_query: Add additional query parameters to the request
1216
-
1217
- extra_body: Add additional JSON properties to the request
1218
-
1219
- timeout: Override the client-level default timeout for this request, in seconds
1220
- """
1221
- return await self._post(
1222
- "/db/insert",
1223
- body=await async_maybe_transform(
1224
- {
1225
- "data": data,
1226
- "table": table,
1227
- "environment": environment,
1228
- },
1229
- db_insert_record_params.DBInsertRecordParams,
1230
- ),
1231
- options=make_request_options(
1232
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1233
- ),
1234
- cast_to=DBInsertRecordResponse,
1235
- )
1236
-
1237
- async def process_nl_query(
1238
- self,
1239
- *,
1240
- question: str,
1241
- context: Dict[str, object] | Omit = omit,
1242
- environment: Literal["development", "staging", "production"] | Omit = omit,
1243
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1244
- # The extra values given here take precedence over values defined on the client or passed to this method.
1245
- extra_headers: Headers | None = None,
1246
- extra_query: Query | None = None,
1247
- extra_body: Body | None = None,
1248
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1249
- ) -> DBProcessNlQueryResponse:
1250
- """
1251
- Converts a natural language question into a SQL query and executes it.
1252
- Organization ID filtering is automatically applied for multi-tenant security.
1253
-
1254
- Args:
1255
- question: Natural language question
1256
-
1257
- context: Optional context for the query
1258
-
1259
- environment: Environment to query (development, staging, production)
1260
-
1261
- extra_headers: Send extra headers
1262
-
1263
- extra_query: Add additional query parameters to the request
1264
-
1265
- extra_body: Add additional JSON properties to the request
1266
-
1267
- timeout: Override the client-level default timeout for this request, in seconds
1268
- """
1269
- return await self._post(
1270
- "/db/nl-query",
1271
- body=await async_maybe_transform(
1272
- {
1273
- "question": question,
1274
- "context": context,
1275
- "environment": environment,
1276
- },
1277
- db_process_nl_query_params.DBProcessNlQueryParams,
1278
- ),
1279
- options=make_request_options(
1280
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1281
- ),
1282
- cast_to=DBProcessNlQueryResponse,
1283
- )
1284
-
1285
- async def recommend(
1286
- self,
1287
- *,
1288
- table: str,
1289
- environment: Literal["development", "staging", "production"] | Omit = omit,
1290
- exclude_ids: SequenceNotStr[str] | Omit = omit,
1291
- limit: float | Omit = omit,
1292
- record_id: Union[str, float] | Omit = omit,
1293
- strategy: Literal["similar", "diverse", "popular"] | Omit = omit,
1294
- user_history: SequenceNotStr[str] | Omit = omit,
1295
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1296
- # The extra values given here take precedence over values defined on the client or passed to this method.
1297
- extra_headers: Headers | None = None,
1298
- extra_query: Query | None = None,
1299
- extra_body: Body | None = None,
1300
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1301
- ) -> DBRecommendResponse:
1302
- """
1303
- Generates item recommendations using vector embeddings and collaborative
1304
- filtering. Supports multiple recommendation strategies including similar items,
1305
- diverse recommendations, and user history-based recommendations.
1306
-
1307
- Args:
1308
- table: Table to generate recommendations from
1309
-
1310
- environment: Environment to search in (development, staging, production)
1311
-
1312
- exclude_ids: Record IDs to exclude from recommendations
1313
-
1314
- limit: Maximum number of recommendations to return
1315
-
1316
- record_id: Source item ID for item-to-item recommendations
1317
-
1318
- strategy: Recommendation strategy to use
1319
-
1320
- user_history: Array of record IDs the user has interacted with
1321
-
1322
- extra_headers: Send extra headers
1323
-
1324
- extra_query: Add additional query parameters to the request
1325
-
1326
- extra_body: Add additional JSON properties to the request
1327
-
1328
- timeout: Override the client-level default timeout for this request, in seconds
1329
- """
1330
- return await self._post(
1331
- "/db/recommend",
1332
- body=await async_maybe_transform(
1333
- {
1334
- "table": table,
1335
- "environment": environment,
1336
- "exclude_ids": exclude_ids,
1337
- "limit": limit,
1338
- "record_id": record_id,
1339
- "strategy": strategy,
1340
- "user_history": user_history,
1341
- },
1342
- db_recommend_params.DBRecommendParams,
1343
- ),
1344
- options=make_request_options(
1345
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1346
- ),
1347
- cast_to=DBRecommendResponse,
1348
- )
1349
-
1350
- async def semantic_search(
1351
- self,
1352
- *,
1353
- query: str,
1354
- environment: Literal["development", "staging", "production"] | Omit = omit,
1355
- filters: Dict[str, object] | Omit = omit,
1356
- limit: float | Omit = omit,
1357
- table: str | Omit = omit,
1358
- tables: SequenceNotStr[str] | Omit = omit,
1359
- threshold: float | Omit = omit,
1360
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1361
- # The extra values given here take precedence over values defined on the client or passed to this method.
1362
- extra_headers: Headers | None = None,
1363
- extra_query: Query | None = None,
1364
- extra_body: Body | None = None,
1365
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1366
- ) -> DBSemanticSearchResponse:
1367
- """
1368
- Performs semantic search across database tables using vector embeddings.
1369
- Supports both single table and cross-table searches with configurable similarity
1370
- thresholds. Returns records with similarity scores and metadata about matched
1371
- fields.
1372
-
1373
- Args:
1374
- query: Natural language search query
1375
-
1376
- environment: Environment to search in (development, staging, production)
1377
-
1378
- filters: Additional WHERE conditions to apply
1379
-
1380
- limit: Maximum number of results to return
1381
-
1382
- table: Single table to search in (optional if tables is provided)
1383
-
1384
- tables: Multiple tables to search across (optional if table is provided)
1385
-
1386
- threshold: Minimum similarity score threshold
1387
-
1388
- extra_headers: Send extra headers
1389
-
1390
- extra_query: Add additional query parameters to the request
1391
-
1392
- extra_body: Add additional JSON properties to the request
1393
-
1394
- timeout: Override the client-level default timeout for this request, in seconds
1395
- """
1396
- return await self._post(
1397
- "/db/semantic-search",
1398
- body=await async_maybe_transform(
1399
- {
1400
- "query": query,
1401
- "environment": environment,
1402
- "filters": filters,
1403
- "limit": limit,
1404
- "table": table,
1405
- "tables": tables,
1406
- "threshold": threshold,
1407
- },
1408
- db_semantic_search_params.DBSemanticSearchParams,
1409
- ),
1410
- options=make_request_options(
1411
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1412
- ),
1413
- cast_to=DBSemanticSearchResponse,
1414
- )
1415
-
1416
- async def update_records(
1417
- self,
1418
- *,
1419
- data: Dict[str, object],
1420
- table: str,
1421
- where: Dict[str, object],
1422
- environment: Literal["development", "staging", "production"] | Omit = omit,
1423
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1424
- # The extra values given here take precedence over values defined on the client or passed to this method.
1425
- extra_headers: Headers | None = None,
1426
- extra_query: Query | None = None,
1427
- extra_body: Body | None = None,
1428
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
1429
- ) -> DBUpdateRecordsResponse:
1430
- """
1431
- Updates records in the specified table that match the where conditions.
1432
- Organization ID filtering is automatically applied for multi-tenant security.
1433
-
1434
- Args:
1435
- data: Data to update
1436
-
1437
- table: Table name to update
1438
-
1439
- where: Where conditions
1440
-
1441
- environment: Environment to update in (development, staging, production)
1442
-
1443
- extra_headers: Send extra headers
1444
-
1445
- extra_query: Add additional query parameters to the request
1446
-
1447
- extra_body: Add additional JSON properties to the request
1448
-
1449
- timeout: Override the client-level default timeout for this request, in seconds
1450
- """
1451
- return await self._put(
1452
- "/db/update",
1453
- body=await async_maybe_transform(
1454
- {
1455
- "data": data,
1456
- "table": table,
1457
- "where": where,
1458
- "environment": environment,
1459
- },
1460
- db_update_records_params.DBUpdateRecordsParams,
1461
- ),
1462
- options=make_request_options(
1463
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1464
- ),
1465
- cast_to=DBUpdateRecordsResponse,
1466
- )
1467
-
1468
-
1469
- class DBResourceWithRawResponse:
1470
- def __init__(self, db: DBResource) -> None:
1471
- self._db = db
1472
-
1473
- self.cluster = to_raw_response_wrapper(
1474
- db.cluster,
1475
- )
1476
- self.delete_records = to_raw_response_wrapper(
1477
- db.delete_records,
1478
- )
1479
- self.detect_anomalies = to_raw_response_wrapper(
1480
- db.detect_anomalies,
1481
- )
1482
- self.execute_batch = to_raw_response_wrapper(
1483
- db.execute_batch,
1484
- )
1485
- self.execute_query = to_raw_response_wrapper(
1486
- db.execute_query,
1487
- )
1488
- self.find_similar = to_raw_response_wrapper(
1489
- db.find_similar,
1490
- )
1491
- self.hybrid_search = to_raw_response_wrapper(
1492
- db.hybrid_search,
1493
- )
1494
- self.insert_record = to_raw_response_wrapper(
1495
- db.insert_record,
1496
- )
1497
- self.process_nl_query = to_raw_response_wrapper(
1498
- db.process_nl_query,
1499
- )
1500
- self.recommend = to_raw_response_wrapper(
1501
- db.recommend,
1502
- )
1503
- self.semantic_search = to_raw_response_wrapper(
1504
- db.semantic_search,
1505
- )
1506
- self.update_records = to_raw_response_wrapper(
1507
- db.update_records,
1508
- )
1509
-
1510
- @cached_property
1511
- def tables(self) -> TablesResourceWithRawResponse:
1512
- return TablesResourceWithRawResponse(self._db.tables)
1513
-
1514
-
1515
- class AsyncDBResourceWithRawResponse:
1516
- def __init__(self, db: AsyncDBResource) -> None:
1517
- self._db = db
1518
-
1519
- self.cluster = async_to_raw_response_wrapper(
1520
- db.cluster,
1521
- )
1522
- self.delete_records = async_to_raw_response_wrapper(
1523
- db.delete_records,
1524
- )
1525
- self.detect_anomalies = async_to_raw_response_wrapper(
1526
- db.detect_anomalies,
1527
- )
1528
- self.execute_batch = async_to_raw_response_wrapper(
1529
- db.execute_batch,
1530
- )
1531
- self.execute_query = async_to_raw_response_wrapper(
1532
- db.execute_query,
1533
- )
1534
- self.find_similar = async_to_raw_response_wrapper(
1535
- db.find_similar,
1536
- )
1537
- self.hybrid_search = async_to_raw_response_wrapper(
1538
- db.hybrid_search,
1539
- )
1540
- self.insert_record = async_to_raw_response_wrapper(
1541
- db.insert_record,
1542
- )
1543
- self.process_nl_query = async_to_raw_response_wrapper(
1544
- db.process_nl_query,
1545
- )
1546
- self.recommend = async_to_raw_response_wrapper(
1547
- db.recommend,
1548
- )
1549
- self.semantic_search = async_to_raw_response_wrapper(
1550
- db.semantic_search,
1551
- )
1552
- self.update_records = async_to_raw_response_wrapper(
1553
- db.update_records,
1554
- )
1555
-
1556
- @cached_property
1557
- def tables(self) -> AsyncTablesResourceWithRawResponse:
1558
- return AsyncTablesResourceWithRawResponse(self._db.tables)
1559
-
1560
-
1561
- class DBResourceWithStreamingResponse:
1562
- def __init__(self, db: DBResource) -> None:
1563
- self._db = db
1564
-
1565
- self.cluster = to_streamed_response_wrapper(
1566
- db.cluster,
1567
- )
1568
- self.delete_records = to_streamed_response_wrapper(
1569
- db.delete_records,
1570
- )
1571
- self.detect_anomalies = to_streamed_response_wrapper(
1572
- db.detect_anomalies,
1573
- )
1574
- self.execute_batch = to_streamed_response_wrapper(
1575
- db.execute_batch,
1576
- )
1577
- self.execute_query = to_streamed_response_wrapper(
1578
- db.execute_query,
1579
- )
1580
- self.find_similar = to_streamed_response_wrapper(
1581
- db.find_similar,
1582
- )
1583
- self.hybrid_search = to_streamed_response_wrapper(
1584
- db.hybrid_search,
1585
- )
1586
- self.insert_record = to_streamed_response_wrapper(
1587
- db.insert_record,
1588
- )
1589
- self.process_nl_query = to_streamed_response_wrapper(
1590
- db.process_nl_query,
1591
- )
1592
- self.recommend = to_streamed_response_wrapper(
1593
- db.recommend,
1594
- )
1595
- self.semantic_search = to_streamed_response_wrapper(
1596
- db.semantic_search,
1597
- )
1598
- self.update_records = to_streamed_response_wrapper(
1599
- db.update_records,
1600
- )
1601
-
1602
- @cached_property
1603
- def tables(self) -> TablesResourceWithStreamingResponse:
1604
- return TablesResourceWithStreamingResponse(self._db.tables)
1605
-
1606
-
1607
- class AsyncDBResourceWithStreamingResponse:
1608
- def __init__(self, db: AsyncDBResource) -> None:
1609
- self._db = db
1610
-
1611
- self.cluster = async_to_streamed_response_wrapper(
1612
- db.cluster,
1613
- )
1614
- self.delete_records = async_to_streamed_response_wrapper(
1615
- db.delete_records,
1616
- )
1617
- self.detect_anomalies = async_to_streamed_response_wrapper(
1618
- db.detect_anomalies,
1619
- )
1620
- self.execute_batch = async_to_streamed_response_wrapper(
1621
- db.execute_batch,
1622
- )
1623
- self.execute_query = async_to_streamed_response_wrapper(
1624
- db.execute_query,
1625
- )
1626
- self.find_similar = async_to_streamed_response_wrapper(
1627
- db.find_similar,
1628
- )
1629
- self.hybrid_search = async_to_streamed_response_wrapper(
1630
- db.hybrid_search,
1631
- )
1632
- self.insert_record = async_to_streamed_response_wrapper(
1633
- db.insert_record,
1634
- )
1635
- self.process_nl_query = async_to_streamed_response_wrapper(
1636
- db.process_nl_query,
1637
- )
1638
- self.recommend = async_to_streamed_response_wrapper(
1639
- db.recommend,
1640
- )
1641
- self.semantic_search = async_to_streamed_response_wrapper(
1642
- db.semantic_search,
1643
- )
1644
- self.update_records = async_to_streamed_response_wrapper(
1645
- db.update_records,
1646
- )
1647
-
1648
- @cached_property
1649
- def tables(self) -> AsyncTablesResourceWithStreamingResponse:
1650
- return AsyncTablesResourceWithStreamingResponse(self._db.tables)