orca-sdk 0.1.10__py3-none-any.whl → 0.1.11__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.
- orca_sdk/_utils/analysis_ui.py +4 -1
- orca_sdk/_utils/data_parsing.py +11 -3
- orca_sdk/_utils/data_parsing_disk_test.py +91 -0
- orca_sdk/_utils/{data_parsing_test.py → data_parsing_torch_test.py} +58 -143
- orca_sdk/_utils/prediction_result_ui.py +4 -1
- orca_sdk/_utils/value_parser.py +44 -17
- orca_sdk/_utils/value_parser_test.py +6 -5
- orca_sdk/async_client.py +78 -18
- orca_sdk/classification_model.py +1 -1
- orca_sdk/classification_model_test.py +69 -22
- orca_sdk/client.py +78 -16
- orca_sdk/conftest.py +87 -7
- orca_sdk/credentials_test.py +5 -8
- orca_sdk/datasource.py +13 -8
- orca_sdk/datasource_test.py +8 -2
- orca_sdk/embedding_model.py +7 -2
- orca_sdk/embedding_model_test.py +29 -0
- orca_sdk/memoryset.py +325 -107
- orca_sdk/memoryset_test.py +87 -178
- orca_sdk/regression_model.py +1 -1
- orca_sdk/regression_model_test.py +44 -0
- orca_sdk/telemetry.py +1 -1
- {orca_sdk-0.1.10.dist-info → orca_sdk-0.1.11.dist-info}/METADATA +3 -5
- orca_sdk-0.1.11.dist-info/RECORD +42 -0
- orca_sdk-0.1.10.dist-info/RECORD +0 -41
- {orca_sdk-0.1.10.dist-info → orca_sdk-0.1.11.dist-info}/WHEEL +0 -0
orca_sdk/async_client.py
CHANGED
|
@@ -29,9 +29,7 @@ from httpx import (
|
|
|
29
29
|
AsyncBaseTransport,
|
|
30
30
|
AsyncClient,
|
|
31
31
|
AsyncHTTPTransport,
|
|
32
|
-
BaseTransport,
|
|
33
32
|
Headers,
|
|
34
|
-
HTTPTransport,
|
|
35
33
|
Limits,
|
|
36
34
|
Proxy,
|
|
37
35
|
Request,
|
|
@@ -211,12 +209,13 @@ class DatasetFilterItem(TypedDict):
|
|
|
211
209
|
value: Any
|
|
212
210
|
|
|
213
211
|
|
|
214
|
-
class
|
|
215
|
-
|
|
212
|
+
class DeleteMemoriesResponse(TypedDict):
|
|
213
|
+
deleted_count: int
|
|
216
214
|
|
|
217
215
|
|
|
218
216
|
class DeleteMemorysetsRequest(TypedDict):
|
|
219
217
|
memoryset_ids: list[str]
|
|
218
|
+
cascade: NotRequired[bool]
|
|
220
219
|
|
|
221
220
|
|
|
222
221
|
class EmbedRequest(TypedDict):
|
|
@@ -292,7 +291,20 @@ class FilterItem(TypedDict):
|
|
|
292
291
|
]
|
|
293
292
|
)
|
|
294
293
|
op: Literal["==", "!=", ">", ">=", "<", "<=", "in", "not in", "like", "contains all", "contains any"]
|
|
295
|
-
value:
|
|
294
|
+
value: (
|
|
295
|
+
str
|
|
296
|
+
| int
|
|
297
|
+
| float
|
|
298
|
+
| bool
|
|
299
|
+
| list[None]
|
|
300
|
+
| list[str]
|
|
301
|
+
| list[str | None]
|
|
302
|
+
| list[int]
|
|
303
|
+
| list[int | None]
|
|
304
|
+
| list[float]
|
|
305
|
+
| list[bool]
|
|
306
|
+
| None
|
|
307
|
+
)
|
|
296
308
|
transform: NotRequired[Literal["length"]]
|
|
297
309
|
|
|
298
310
|
|
|
@@ -355,6 +367,13 @@ class LabelPercentage(TypedDict):
|
|
|
355
367
|
percentage: float
|
|
356
368
|
|
|
357
369
|
|
|
370
|
+
class LabeledBatchMemoryUpdatePatch(TypedDict):
|
|
371
|
+
metadata: NotRequired[dict[str, str | int | float | bool | None] | None]
|
|
372
|
+
source_id: NotRequired[str | None]
|
|
373
|
+
partition_id: NotRequired[str | None]
|
|
374
|
+
label: NotRequired[int | None]
|
|
375
|
+
|
|
376
|
+
|
|
358
377
|
class LabeledExample(TypedDict):
|
|
359
378
|
text: str
|
|
360
379
|
label_name: str
|
|
@@ -373,8 +392,6 @@ class ListMemoriesRequest(TypedDict):
|
|
|
373
392
|
offset: NotRequired[int]
|
|
374
393
|
limit: NotRequired[int]
|
|
375
394
|
filters: NotRequired[list[FilterItem]]
|
|
376
|
-
partition_id: NotRequired[str | None]
|
|
377
|
-
partition_filter_mode: NotRequired[Literal["ignore_partitions", "include_global", "exclude_global", "only_global"]]
|
|
378
395
|
|
|
379
396
|
|
|
380
397
|
class LookupRequest(TypedDict):
|
|
@@ -526,6 +543,7 @@ class NotFoundErrorResponse(TypedDict):
|
|
|
526
543
|
"api_key",
|
|
527
544
|
"datasource",
|
|
528
545
|
"memoryset",
|
|
546
|
+
"predictive_model",
|
|
529
547
|
"classification_model",
|
|
530
548
|
"regression_model",
|
|
531
549
|
"prediction",
|
|
@@ -730,6 +748,13 @@ class ScorePredictionWithMemoriesAndFeedback(TypedDict):
|
|
|
730
748
|
feedbacks: list[PredictionFeedback]
|
|
731
749
|
|
|
732
750
|
|
|
751
|
+
class ScoredBatchMemoryUpdatePatch(TypedDict):
|
|
752
|
+
metadata: NotRequired[dict[str, str | int | float | bool | None] | None]
|
|
753
|
+
source_id: NotRequired[str | None]
|
|
754
|
+
partition_id: NotRequired[str | None]
|
|
755
|
+
score: NotRequired[float | None]
|
|
756
|
+
|
|
757
|
+
|
|
733
758
|
class ScoredMemory(TypedDict):
|
|
734
759
|
value: str | bytes
|
|
735
760
|
embedding: list[float]
|
|
@@ -835,6 +860,10 @@ class UnauthorizedErrorResponse(TypedDict):
|
|
|
835
860
|
reason: str
|
|
836
861
|
|
|
837
862
|
|
|
863
|
+
class UpdateMemoriesResponse(TypedDict):
|
|
864
|
+
updated_count: int
|
|
865
|
+
|
|
866
|
+
|
|
838
867
|
class UpdateOrgPlanRequest(TypedDict):
|
|
839
868
|
tier: Literal["FREE", "PRO", "ENTERPRISE", "CANCELLED"]
|
|
840
869
|
|
|
@@ -885,6 +914,7 @@ class GetMemorysetByNameOrIdParams(TypedDict):
|
|
|
885
914
|
|
|
886
915
|
class DeleteMemorysetByNameOrIdParams(TypedDict):
|
|
887
916
|
name_or_id: str
|
|
917
|
+
cascade: NotRequired[bool]
|
|
888
918
|
|
|
889
919
|
|
|
890
920
|
class PostGpuMemorysetByNameOrIdLookupParams(TypedDict):
|
|
@@ -965,6 +995,7 @@ class GetFinetunedEmbeddingModelByNameOrIdParams(TypedDict):
|
|
|
965
995
|
|
|
966
996
|
class DeleteFinetunedEmbeddingModelByNameOrIdParams(TypedDict):
|
|
967
997
|
name_or_id: str
|
|
998
|
+
cascade: NotRequired[bool]
|
|
968
999
|
|
|
969
1000
|
|
|
970
1001
|
class PostGpuFinetunedEmbeddingModelByNameOrIdEmbeddingParams(TypedDict):
|
|
@@ -1058,6 +1089,20 @@ class GetDatasourceByNameOrIdDownloadParams(TypedDict):
|
|
|
1058
1089
|
"""
|
|
1059
1090
|
|
|
1060
1091
|
|
|
1092
|
+
class GetClassificationModelParams(TypedDict):
|
|
1093
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1094
|
+
"""
|
|
1095
|
+
Filter by memoryset name or ID
|
|
1096
|
+
"""
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
class GetRegressionModelParams(TypedDict):
|
|
1100
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1101
|
+
"""
|
|
1102
|
+
Filter by memoryset name or ID
|
|
1103
|
+
"""
|
|
1104
|
+
|
|
1105
|
+
|
|
1061
1106
|
class PatchClassificationModelByNameOrIdParams(TypedDict):
|
|
1062
1107
|
name_or_id: str
|
|
1063
1108
|
|
|
@@ -1082,6 +1127,13 @@ class DeleteRegressionModelByNameOrIdParams(TypedDict):
|
|
|
1082
1127
|
name_or_id: str
|
|
1083
1128
|
|
|
1084
1129
|
|
|
1130
|
+
class GetPredictiveModelParams(TypedDict):
|
|
1131
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1132
|
+
"""
|
|
1133
|
+
Filter by memoryset name or ID
|
|
1134
|
+
"""
|
|
1135
|
+
|
|
1136
|
+
|
|
1085
1137
|
class PostGpuClassificationModelByNameOrIdPredictionParams(TypedDict):
|
|
1086
1138
|
name_or_id: str
|
|
1087
1139
|
|
|
@@ -1404,6 +1456,11 @@ class DatasourceMetadata(TypedDict):
|
|
|
1404
1456
|
updated_at: str
|
|
1405
1457
|
|
|
1406
1458
|
|
|
1459
|
+
class DeleteMemoriesRequest(TypedDict):
|
|
1460
|
+
memory_ids: NotRequired[list[str] | None]
|
|
1461
|
+
filters: NotRequired[list[FilterItem] | None]
|
|
1462
|
+
|
|
1463
|
+
|
|
1407
1464
|
class EmbeddingEvaluationResponse(TypedDict):
|
|
1408
1465
|
job_id: str
|
|
1409
1466
|
org_id: str
|
|
@@ -1704,7 +1761,10 @@ class WorkerInfo(TypedDict):
|
|
|
1704
1761
|
PatchGpuMemorysetByNameOrIdMemoryRequest: TypeAlias = LabeledMemoryUpdate | ScoredMemoryUpdate
|
|
1705
1762
|
|
|
1706
1763
|
|
|
1707
|
-
|
|
1764
|
+
class BatchMemoryUpdateRequest(TypedDict):
|
|
1765
|
+
updates: NotRequired[list[LabeledMemoryUpdate | ScoredMemoryUpdate] | None]
|
|
1766
|
+
filters: NotRequired[list[FilterItem] | None]
|
|
1767
|
+
patch: NotRequired[LabeledBatchMemoryUpdatePatch | ScoredBatchMemoryUpdatePatch | None]
|
|
1708
1768
|
|
|
1709
1769
|
|
|
1710
1770
|
class CascadingEditSuggestion(TypedDict):
|
|
@@ -1992,7 +2052,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
1992
2052
|
self,
|
|
1993
2053
|
path: Literal["/memoryset"],
|
|
1994
2054
|
*,
|
|
1995
|
-
params: GetMemorysetParams,
|
|
2055
|
+
params: GetMemorysetParams | None = None,
|
|
1996
2056
|
parse_as: Literal["json"] = "json",
|
|
1997
2057
|
headers: HeaderTypes | None = None,
|
|
1998
2058
|
cookies: CookieTypes | None = None,
|
|
@@ -2048,7 +2108,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2048
2108
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2049
2109
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2050
2110
|
extensions: RequestExtensions | None = None,
|
|
2051
|
-
) -> list[list[LabeledMemory]] | list[list[ScoredMemory]]:
|
|
2111
|
+
) -> list[list[LabeledMemory]] | list[list[ScoredMemory]] | None:
|
|
2052
2112
|
pass
|
|
2053
2113
|
|
|
2054
2114
|
@overload
|
|
@@ -2326,7 +2386,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2326
2386
|
self,
|
|
2327
2387
|
path: Literal["/classification_model"],
|
|
2328
2388
|
*,
|
|
2329
|
-
params: None = None,
|
|
2389
|
+
params: GetClassificationModelParams | None = None,
|
|
2330
2390
|
parse_as: Literal["json"] = "json",
|
|
2331
2391
|
headers: HeaderTypes | None = None,
|
|
2332
2392
|
cookies: CookieTypes | None = None,
|
|
@@ -2342,7 +2402,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2342
2402
|
self,
|
|
2343
2403
|
path: Literal["/regression_model"],
|
|
2344
2404
|
*,
|
|
2345
|
-
params: None = None,
|
|
2405
|
+
params: GetRegressionModelParams | None = None,
|
|
2346
2406
|
parse_as: Literal["json"] = "json",
|
|
2347
2407
|
headers: HeaderTypes | None = None,
|
|
2348
2408
|
cookies: CookieTypes | None = None,
|
|
@@ -2390,7 +2450,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2390
2450
|
self,
|
|
2391
2451
|
path: Literal["/predictive_model"],
|
|
2392
2452
|
*,
|
|
2393
|
-
params: None = None,
|
|
2453
|
+
params: GetPredictiveModelParams | None = None,
|
|
2394
2454
|
parse_as: Literal["json"] = "json",
|
|
2395
2455
|
headers: HeaderTypes | None = None,
|
|
2396
2456
|
cookies: CookieTypes | None = None,
|
|
@@ -2502,7 +2562,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2502
2562
|
self,
|
|
2503
2563
|
path: Literal["/job"],
|
|
2504
2564
|
*,
|
|
2505
|
-
params: GetJobParams,
|
|
2565
|
+
params: GetJobParams | None = None,
|
|
2506
2566
|
parse_as: Literal["json"] = "json",
|
|
2507
2567
|
headers: HeaderTypes | None = None,
|
|
2508
2568
|
cookies: CookieTypes | None = None,
|
|
@@ -2518,7 +2578,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2518
2578
|
self,
|
|
2519
2579
|
path: Literal["/worker"],
|
|
2520
2580
|
*,
|
|
2521
|
-
params: GetWorkerParams,
|
|
2581
|
+
params: GetWorkerParams | None = None,
|
|
2522
2582
|
parse_as: Literal["json"] = "json",
|
|
2523
2583
|
headers: HeaderTypes | None = None,
|
|
2524
2584
|
cookies: CookieTypes | None = None,
|
|
@@ -3150,7 +3210,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
3150
3210
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3151
3211
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3152
3212
|
extensions: RequestExtensions | None = None,
|
|
3153
|
-
) ->
|
|
3213
|
+
) -> DeleteMemoriesResponse:
|
|
3154
3214
|
pass
|
|
3155
3215
|
|
|
3156
3216
|
@overload
|
|
@@ -3867,7 +3927,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
3867
3927
|
path: Literal["/gpu/memoryset/{name_or_id}/memories"],
|
|
3868
3928
|
*,
|
|
3869
3929
|
params: PatchGpuMemorysetByNameOrIdMemoriesParams,
|
|
3870
|
-
json:
|
|
3930
|
+
json: BatchMemoryUpdateRequest,
|
|
3871
3931
|
data: None = None,
|
|
3872
3932
|
files: None = None,
|
|
3873
3933
|
content: None = None,
|
|
@@ -3878,7 +3938,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
3878
3938
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3879
3939
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3880
3940
|
extensions: RequestExtensions | None = None,
|
|
3881
|
-
) ->
|
|
3941
|
+
) -> UpdateMemoriesResponse:
|
|
3882
3942
|
pass
|
|
3883
3943
|
|
|
3884
3944
|
@overload
|
orca_sdk/classification_model.py
CHANGED
|
@@ -279,7 +279,7 @@ class ClassificationModel:
|
|
|
279
279
|
List of handles to all classification models in the OrcaCloud
|
|
280
280
|
"""
|
|
281
281
|
client = OrcaClient._resolve_client()
|
|
282
|
-
return [cls(metadata) for metadata in client.GET("/classification_model")]
|
|
282
|
+
return [cls(metadata) for metadata in client.GET("/classification_model", params={})]
|
|
283
283
|
|
|
284
284
|
@classmethod
|
|
285
285
|
def drop(cls, name_or_id: str, if_not_exists: DropMode = "error"):
|
|
@@ -108,6 +108,14 @@ def test_list_models_unauthorized(unauthorized_client, classification_model: Cla
|
|
|
108
108
|
assert ClassificationModel.all() == []
|
|
109
109
|
|
|
110
110
|
|
|
111
|
+
def test_memoryset_classification_models_property(
|
|
112
|
+
classification_model: ClassificationModel, readonly_memoryset: LabeledMemoryset
|
|
113
|
+
):
|
|
114
|
+
models = readonly_memoryset.classification_models
|
|
115
|
+
assert len(models) > 0
|
|
116
|
+
assert any(model.id == classification_model.id for model in models)
|
|
117
|
+
|
|
118
|
+
|
|
111
119
|
def test_update_model_attributes(classification_model: ClassificationModel):
|
|
112
120
|
classification_model.description = "New description"
|
|
113
121
|
assert classification_model.description == "New description"
|
|
@@ -162,6 +170,29 @@ def test_delete_memoryset_before_model_constraint_violation(hf_dataset):
|
|
|
162
170
|
LabeledMemoryset.drop(memoryset.id)
|
|
163
171
|
|
|
164
172
|
|
|
173
|
+
def test_delete_memoryset_with_model_cascade(hf_dataset):
|
|
174
|
+
"""Test that cascade=False prevents deletion and cascade=True allows it."""
|
|
175
|
+
memoryset = LabeledMemoryset.from_hf_dataset("test_memoryset_cascade_delete", hf_dataset)
|
|
176
|
+
model = ClassificationModel.create("test_model_cascade_delete", memoryset)
|
|
177
|
+
|
|
178
|
+
# Verify model exists
|
|
179
|
+
assert ClassificationModel.open(model.name) is not None
|
|
180
|
+
|
|
181
|
+
# Without cascade, deletion should fail
|
|
182
|
+
with pytest.raises(RuntimeError):
|
|
183
|
+
LabeledMemoryset.drop(memoryset.id, cascade=False)
|
|
184
|
+
|
|
185
|
+
# Model should still exist
|
|
186
|
+
assert ClassificationModel.exists(model.name)
|
|
187
|
+
|
|
188
|
+
# With cascade, deletion should succeed
|
|
189
|
+
LabeledMemoryset.drop(memoryset.id, cascade=True)
|
|
190
|
+
|
|
191
|
+
# Model should be deleted along with the memoryset
|
|
192
|
+
assert not ClassificationModel.exists(model.name)
|
|
193
|
+
assert not LabeledMemoryset.exists(memoryset.name)
|
|
194
|
+
|
|
195
|
+
|
|
165
196
|
@pytest.mark.parametrize("data_type", ["dataset", "datasource"])
|
|
166
197
|
def test_evaluate(classification_model, eval_datasource: Datasource, eval_dataset: Dataset, data_type):
|
|
167
198
|
result = (
|
|
@@ -683,28 +714,27 @@ def test_predict_with_memoryset_update(writable_memoryset: LabeledMemoryset):
|
|
|
683
714
|
num_classes=2,
|
|
684
715
|
memory_lookup_count=3,
|
|
685
716
|
)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
ClassificationModel.drop("test_predict_with_memoryset_update")
|
|
717
|
+
try:
|
|
718
|
+
prediction = model.predict("Do you love soup?", partition_filter_mode="ignore_partitions")
|
|
719
|
+
assert prediction.label == 0
|
|
720
|
+
assert prediction.label_name == "soup"
|
|
721
|
+
# insert new memories
|
|
722
|
+
writable_memoryset.insert(
|
|
723
|
+
[
|
|
724
|
+
{"value": "Do you love soup?", "label": 1, "key": "g1"},
|
|
725
|
+
{"value": "Do you love soup for dinner?", "label": 1, "key": "g2"},
|
|
726
|
+
{"value": "Do you love crackers?", "label": 1, "key": "g2"},
|
|
727
|
+
{"value": "Do you love broth?", "label": 1, "key": "g2"},
|
|
728
|
+
{"value": "Do you love chicken soup?", "label": 1, "key": "g2"},
|
|
729
|
+
{"value": "Do you love chicken soup for dinner?", "label": 1, "key": "g2"},
|
|
730
|
+
{"value": "Do you love chicken soup for dinner?", "label": 1, "key": "g2"},
|
|
731
|
+
],
|
|
732
|
+
)
|
|
733
|
+
prediction = model.predict("Do you love soup?")
|
|
734
|
+
assert prediction.label == 1
|
|
735
|
+
assert prediction.label_name == "cats"
|
|
736
|
+
finally:
|
|
737
|
+
ClassificationModel.drop("test_predict_with_memoryset_update")
|
|
708
738
|
|
|
709
739
|
|
|
710
740
|
def test_last_prediction_with_batch(classification_model: ClassificationModel):
|
|
@@ -828,6 +858,23 @@ def test_predict_with_prompt(classification_model: ClassificationModel):
|
|
|
828
858
|
assert prediction_without_prompt.label is not None
|
|
829
859
|
|
|
830
860
|
|
|
861
|
+
def test_predict_with_empty_partition(fully_partitioned_classification_resources):
|
|
862
|
+
datasource, memoryset, classification_model = fully_partitioned_classification_resources
|
|
863
|
+
|
|
864
|
+
assert memoryset.length == 15
|
|
865
|
+
|
|
866
|
+
with pytest.raises(RuntimeError, match="lookup failed to return the correct number of memories"):
|
|
867
|
+
classification_model.predict("i love cats", partition_filter_mode="only_global")
|
|
868
|
+
|
|
869
|
+
with pytest.raises(RuntimeError, match="lookup failed to return the correct number of memories"):
|
|
870
|
+
classification_model.predict(
|
|
871
|
+
"i love cats", partition_filter_mode="exclude_global", partition_id="p_does_not_exist"
|
|
872
|
+
)
|
|
873
|
+
|
|
874
|
+
with pytest.raises(RuntimeError, match="lookup failed to return the correct number of memories"):
|
|
875
|
+
classification_model.evaluate(datasource, partition_filter_mode="only_global")
|
|
876
|
+
|
|
877
|
+
|
|
831
878
|
@pytest.mark.asyncio
|
|
832
879
|
async def test_predict_async_single(classification_model: ClassificationModel, label_names: list[str]):
|
|
833
880
|
"""Test async prediction with a single value"""
|
orca_sdk/client.py
CHANGED
|
@@ -209,12 +209,13 @@ class DatasetFilterItem(TypedDict):
|
|
|
209
209
|
value: Any
|
|
210
210
|
|
|
211
211
|
|
|
212
|
-
class
|
|
213
|
-
|
|
212
|
+
class DeleteMemoriesResponse(TypedDict):
|
|
213
|
+
deleted_count: int
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
class DeleteMemorysetsRequest(TypedDict):
|
|
217
217
|
memoryset_ids: list[str]
|
|
218
|
+
cascade: NotRequired[bool]
|
|
218
219
|
|
|
219
220
|
|
|
220
221
|
class EmbedRequest(TypedDict):
|
|
@@ -290,7 +291,20 @@ class FilterItem(TypedDict):
|
|
|
290
291
|
]
|
|
291
292
|
)
|
|
292
293
|
op: Literal["==", "!=", ">", ">=", "<", "<=", "in", "not in", "like", "contains all", "contains any"]
|
|
293
|
-
value:
|
|
294
|
+
value: (
|
|
295
|
+
str
|
|
296
|
+
| int
|
|
297
|
+
| float
|
|
298
|
+
| bool
|
|
299
|
+
| list[None]
|
|
300
|
+
| list[str]
|
|
301
|
+
| list[str | None]
|
|
302
|
+
| list[int]
|
|
303
|
+
| list[int | None]
|
|
304
|
+
| list[float]
|
|
305
|
+
| list[bool]
|
|
306
|
+
| None
|
|
307
|
+
)
|
|
294
308
|
transform: NotRequired[Literal["length"]]
|
|
295
309
|
|
|
296
310
|
|
|
@@ -353,6 +367,13 @@ class LabelPercentage(TypedDict):
|
|
|
353
367
|
percentage: float
|
|
354
368
|
|
|
355
369
|
|
|
370
|
+
class LabeledBatchMemoryUpdatePatch(TypedDict):
|
|
371
|
+
metadata: NotRequired[dict[str, str | int | float | bool | None] | None]
|
|
372
|
+
source_id: NotRequired[str | None]
|
|
373
|
+
partition_id: NotRequired[str | None]
|
|
374
|
+
label: NotRequired[int | None]
|
|
375
|
+
|
|
376
|
+
|
|
356
377
|
class LabeledExample(TypedDict):
|
|
357
378
|
text: str
|
|
358
379
|
label_name: str
|
|
@@ -371,8 +392,6 @@ class ListMemoriesRequest(TypedDict):
|
|
|
371
392
|
offset: NotRequired[int]
|
|
372
393
|
limit: NotRequired[int]
|
|
373
394
|
filters: NotRequired[list[FilterItem]]
|
|
374
|
-
partition_id: NotRequired[str | None]
|
|
375
|
-
partition_filter_mode: NotRequired[Literal["ignore_partitions", "include_global", "exclude_global", "only_global"]]
|
|
376
395
|
|
|
377
396
|
|
|
378
397
|
class LookupRequest(TypedDict):
|
|
@@ -524,6 +543,7 @@ class NotFoundErrorResponse(TypedDict):
|
|
|
524
543
|
"api_key",
|
|
525
544
|
"datasource",
|
|
526
545
|
"memoryset",
|
|
546
|
+
"predictive_model",
|
|
527
547
|
"classification_model",
|
|
528
548
|
"regression_model",
|
|
529
549
|
"prediction",
|
|
@@ -728,6 +748,13 @@ class ScorePredictionWithMemoriesAndFeedback(TypedDict):
|
|
|
728
748
|
feedbacks: list[PredictionFeedback]
|
|
729
749
|
|
|
730
750
|
|
|
751
|
+
class ScoredBatchMemoryUpdatePatch(TypedDict):
|
|
752
|
+
metadata: NotRequired[dict[str, str | int | float | bool | None] | None]
|
|
753
|
+
source_id: NotRequired[str | None]
|
|
754
|
+
partition_id: NotRequired[str | None]
|
|
755
|
+
score: NotRequired[float | None]
|
|
756
|
+
|
|
757
|
+
|
|
731
758
|
class ScoredMemory(TypedDict):
|
|
732
759
|
value: str | bytes
|
|
733
760
|
embedding: list[float]
|
|
@@ -833,6 +860,10 @@ class UnauthorizedErrorResponse(TypedDict):
|
|
|
833
860
|
reason: str
|
|
834
861
|
|
|
835
862
|
|
|
863
|
+
class UpdateMemoriesResponse(TypedDict):
|
|
864
|
+
updated_count: int
|
|
865
|
+
|
|
866
|
+
|
|
836
867
|
class UpdateOrgPlanRequest(TypedDict):
|
|
837
868
|
tier: Literal["FREE", "PRO", "ENTERPRISE", "CANCELLED"]
|
|
838
869
|
|
|
@@ -883,6 +914,7 @@ class GetMemorysetByNameOrIdParams(TypedDict):
|
|
|
883
914
|
|
|
884
915
|
class DeleteMemorysetByNameOrIdParams(TypedDict):
|
|
885
916
|
name_or_id: str
|
|
917
|
+
cascade: NotRequired[bool]
|
|
886
918
|
|
|
887
919
|
|
|
888
920
|
class PostGpuMemorysetByNameOrIdLookupParams(TypedDict):
|
|
@@ -963,6 +995,7 @@ class GetFinetunedEmbeddingModelByNameOrIdParams(TypedDict):
|
|
|
963
995
|
|
|
964
996
|
class DeleteFinetunedEmbeddingModelByNameOrIdParams(TypedDict):
|
|
965
997
|
name_or_id: str
|
|
998
|
+
cascade: NotRequired[bool]
|
|
966
999
|
|
|
967
1000
|
|
|
968
1001
|
class PostGpuFinetunedEmbeddingModelByNameOrIdEmbeddingParams(TypedDict):
|
|
@@ -1056,6 +1089,20 @@ class GetDatasourceByNameOrIdDownloadParams(TypedDict):
|
|
|
1056
1089
|
"""
|
|
1057
1090
|
|
|
1058
1091
|
|
|
1092
|
+
class GetClassificationModelParams(TypedDict):
|
|
1093
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1094
|
+
"""
|
|
1095
|
+
Filter by memoryset name or ID
|
|
1096
|
+
"""
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
class GetRegressionModelParams(TypedDict):
|
|
1100
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1101
|
+
"""
|
|
1102
|
+
Filter by memoryset name or ID
|
|
1103
|
+
"""
|
|
1104
|
+
|
|
1105
|
+
|
|
1059
1106
|
class PatchClassificationModelByNameOrIdParams(TypedDict):
|
|
1060
1107
|
name_or_id: str
|
|
1061
1108
|
|
|
@@ -1080,6 +1127,13 @@ class DeleteRegressionModelByNameOrIdParams(TypedDict):
|
|
|
1080
1127
|
name_or_id: str
|
|
1081
1128
|
|
|
1082
1129
|
|
|
1130
|
+
class GetPredictiveModelParams(TypedDict):
|
|
1131
|
+
memoryset_name_or_id: NotRequired[str | None]
|
|
1132
|
+
"""
|
|
1133
|
+
Filter by memoryset name or ID
|
|
1134
|
+
"""
|
|
1135
|
+
|
|
1136
|
+
|
|
1083
1137
|
class PostGpuClassificationModelByNameOrIdPredictionParams(TypedDict):
|
|
1084
1138
|
name_or_id: str
|
|
1085
1139
|
|
|
@@ -1402,6 +1456,11 @@ class DatasourceMetadata(TypedDict):
|
|
|
1402
1456
|
updated_at: str
|
|
1403
1457
|
|
|
1404
1458
|
|
|
1459
|
+
class DeleteMemoriesRequest(TypedDict):
|
|
1460
|
+
memory_ids: NotRequired[list[str] | None]
|
|
1461
|
+
filters: NotRequired[list[FilterItem] | None]
|
|
1462
|
+
|
|
1463
|
+
|
|
1405
1464
|
class EmbeddingEvaluationResponse(TypedDict):
|
|
1406
1465
|
job_id: str
|
|
1407
1466
|
org_id: str
|
|
@@ -1702,7 +1761,10 @@ class WorkerInfo(TypedDict):
|
|
|
1702
1761
|
PatchGpuMemorysetByNameOrIdMemoryRequest: TypeAlias = LabeledMemoryUpdate | ScoredMemoryUpdate
|
|
1703
1762
|
|
|
1704
1763
|
|
|
1705
|
-
|
|
1764
|
+
class BatchMemoryUpdateRequest(TypedDict):
|
|
1765
|
+
updates: NotRequired[list[LabeledMemoryUpdate | ScoredMemoryUpdate] | None]
|
|
1766
|
+
filters: NotRequired[list[FilterItem] | None]
|
|
1767
|
+
patch: NotRequired[LabeledBatchMemoryUpdatePatch | ScoredBatchMemoryUpdatePatch | None]
|
|
1706
1768
|
|
|
1707
1769
|
|
|
1708
1770
|
class CascadingEditSuggestion(TypedDict):
|
|
@@ -1990,7 +2052,7 @@ class OrcaClient(Client):
|
|
|
1990
2052
|
self,
|
|
1991
2053
|
path: Literal["/memoryset"],
|
|
1992
2054
|
*,
|
|
1993
|
-
params: GetMemorysetParams,
|
|
2055
|
+
params: GetMemorysetParams | None = None,
|
|
1994
2056
|
parse_as: Literal["json"] = "json",
|
|
1995
2057
|
headers: HeaderTypes | None = None,
|
|
1996
2058
|
cookies: CookieTypes | None = None,
|
|
@@ -2046,7 +2108,7 @@ class OrcaClient(Client):
|
|
|
2046
2108
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2047
2109
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2048
2110
|
extensions: RequestExtensions | None = None,
|
|
2049
|
-
) -> list[list[LabeledMemory]] | list[list[ScoredMemory]]:
|
|
2111
|
+
) -> list[list[LabeledMemory]] | list[list[ScoredMemory]] | None:
|
|
2050
2112
|
pass
|
|
2051
2113
|
|
|
2052
2114
|
@overload
|
|
@@ -2324,7 +2386,7 @@ class OrcaClient(Client):
|
|
|
2324
2386
|
self,
|
|
2325
2387
|
path: Literal["/classification_model"],
|
|
2326
2388
|
*,
|
|
2327
|
-
params: None = None,
|
|
2389
|
+
params: GetClassificationModelParams | None = None,
|
|
2328
2390
|
parse_as: Literal["json"] = "json",
|
|
2329
2391
|
headers: HeaderTypes | None = None,
|
|
2330
2392
|
cookies: CookieTypes | None = None,
|
|
@@ -2340,7 +2402,7 @@ class OrcaClient(Client):
|
|
|
2340
2402
|
self,
|
|
2341
2403
|
path: Literal["/regression_model"],
|
|
2342
2404
|
*,
|
|
2343
|
-
params: None = None,
|
|
2405
|
+
params: GetRegressionModelParams | None = None,
|
|
2344
2406
|
parse_as: Literal["json"] = "json",
|
|
2345
2407
|
headers: HeaderTypes | None = None,
|
|
2346
2408
|
cookies: CookieTypes | None = None,
|
|
@@ -2388,7 +2450,7 @@ class OrcaClient(Client):
|
|
|
2388
2450
|
self,
|
|
2389
2451
|
path: Literal["/predictive_model"],
|
|
2390
2452
|
*,
|
|
2391
|
-
params: None = None,
|
|
2453
|
+
params: GetPredictiveModelParams | None = None,
|
|
2392
2454
|
parse_as: Literal["json"] = "json",
|
|
2393
2455
|
headers: HeaderTypes | None = None,
|
|
2394
2456
|
cookies: CookieTypes | None = None,
|
|
@@ -2500,7 +2562,7 @@ class OrcaClient(Client):
|
|
|
2500
2562
|
self,
|
|
2501
2563
|
path: Literal["/job"],
|
|
2502
2564
|
*,
|
|
2503
|
-
params: GetJobParams,
|
|
2565
|
+
params: GetJobParams | None = None,
|
|
2504
2566
|
parse_as: Literal["json"] = "json",
|
|
2505
2567
|
headers: HeaderTypes | None = None,
|
|
2506
2568
|
cookies: CookieTypes | None = None,
|
|
@@ -2516,7 +2578,7 @@ class OrcaClient(Client):
|
|
|
2516
2578
|
self,
|
|
2517
2579
|
path: Literal["/worker"],
|
|
2518
2580
|
*,
|
|
2519
|
-
params: GetWorkerParams,
|
|
2581
|
+
params: GetWorkerParams | None = None,
|
|
2520
2582
|
parse_as: Literal["json"] = "json",
|
|
2521
2583
|
headers: HeaderTypes | None = None,
|
|
2522
2584
|
cookies: CookieTypes | None = None,
|
|
@@ -3148,7 +3210,7 @@ class OrcaClient(Client):
|
|
|
3148
3210
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3149
3211
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3150
3212
|
extensions: RequestExtensions | None = None,
|
|
3151
|
-
) ->
|
|
3213
|
+
) -> DeleteMemoriesResponse:
|
|
3152
3214
|
pass
|
|
3153
3215
|
|
|
3154
3216
|
@overload
|
|
@@ -3865,7 +3927,7 @@ class OrcaClient(Client):
|
|
|
3865
3927
|
path: Literal["/gpu/memoryset/{name_or_id}/memories"],
|
|
3866
3928
|
*,
|
|
3867
3929
|
params: PatchGpuMemorysetByNameOrIdMemoriesParams,
|
|
3868
|
-
json:
|
|
3930
|
+
json: BatchMemoryUpdateRequest,
|
|
3869
3931
|
data: None = None,
|
|
3870
3932
|
files: None = None,
|
|
3871
3933
|
content: None = None,
|
|
@@ -3876,7 +3938,7 @@ class OrcaClient(Client):
|
|
|
3876
3938
|
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3877
3939
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3878
3940
|
extensions: RequestExtensions | None = None,
|
|
3879
|
-
) ->
|
|
3941
|
+
) -> UpdateMemoriesResponse:
|
|
3880
3942
|
pass
|
|
3881
3943
|
|
|
3882
3944
|
@overload
|