knowledge2 0.4.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.
- knowledge2-0.4.0.dist-info/METADATA +556 -0
- knowledge2-0.4.0.dist-info/RECORD +139 -0
- knowledge2-0.4.0.dist-info/WHEEL +5 -0
- knowledge2-0.4.0.dist-info/top_level.txt +1 -0
- sdk/__init__.py +70 -0
- sdk/_async_base.py +525 -0
- sdk/_async_paging.py +57 -0
- sdk/_base.py +541 -0
- sdk/_logging.py +41 -0
- sdk/_paging.py +73 -0
- sdk/_preview.py +70 -0
- sdk/_raw_response.py +25 -0
- sdk/_request_options.py +51 -0
- sdk/_transport.py +144 -0
- sdk/_validation.py +25 -0
- sdk/_validation_response.py +36 -0
- sdk/_version.py +3 -0
- sdk/async_client.py +320 -0
- sdk/async_resources/__init__.py +45 -0
- sdk/async_resources/_mixin_base.py +42 -0
- sdk/async_resources/a2a.py +230 -0
- sdk/async_resources/agents.py +489 -0
- sdk/async_resources/audit.py +145 -0
- sdk/async_resources/auth.py +133 -0
- sdk/async_resources/console.py +409 -0
- sdk/async_resources/corpora.py +276 -0
- sdk/async_resources/deployments.py +106 -0
- sdk/async_resources/documents.py +592 -0
- sdk/async_resources/feeds.py +248 -0
- sdk/async_resources/indexes.py +208 -0
- sdk/async_resources/jobs.py +165 -0
- sdk/async_resources/metadata.py +48 -0
- sdk/async_resources/models.py +102 -0
- sdk/async_resources/onboarding.py +538 -0
- sdk/async_resources/orgs.py +37 -0
- sdk/async_resources/pipelines.py +523 -0
- sdk/async_resources/projects.py +90 -0
- sdk/async_resources/search.py +262 -0
- sdk/async_resources/training.py +357 -0
- sdk/async_resources/usage.py +91 -0
- sdk/client.py +417 -0
- sdk/config.py +182 -0
- sdk/errors.py +178 -0
- sdk/examples/auth_factory.py +34 -0
- sdk/examples/batch_operations.py +57 -0
- sdk/examples/document_upload.py +56 -0
- sdk/examples/e2e_lifecycle.py +213 -0
- sdk/examples/error_handling.py +61 -0
- sdk/examples/pagination.py +64 -0
- sdk/examples/quickstart.py +36 -0
- sdk/examples/request_options.py +44 -0
- sdk/examples/search.py +64 -0
- sdk/integrations/__init__.py +57 -0
- sdk/integrations/_client.py +101 -0
- sdk/integrations/langchain/__init__.py +6 -0
- sdk/integrations/langchain/retriever.py +166 -0
- sdk/integrations/langchain/tools.py +108 -0
- sdk/integrations/llamaindex/__init__.py +11 -0
- sdk/integrations/llamaindex/filters.py +78 -0
- sdk/integrations/llamaindex/retriever.py +162 -0
- sdk/integrations/llamaindex/tools.py +109 -0
- sdk/integrations/llamaindex/vector_store.py +320 -0
- sdk/models/__init__.py +18 -0
- sdk/models/_base.py +24 -0
- sdk/models/_registry.py +457 -0
- sdk/models/a2a.py +92 -0
- sdk/models/agents.py +109 -0
- sdk/models/audit.py +28 -0
- sdk/models/auth.py +49 -0
- sdk/models/chunks.py +20 -0
- sdk/models/common.py +14 -0
- sdk/models/console.py +103 -0
- sdk/models/corpora.py +48 -0
- sdk/models/deployments.py +13 -0
- sdk/models/documents.py +126 -0
- sdk/models/embeddings.py +24 -0
- sdk/models/evaluation.py +17 -0
- sdk/models/feedback.py +9 -0
- sdk/models/feeds.py +57 -0
- sdk/models/indexes.py +36 -0
- sdk/models/jobs.py +52 -0
- sdk/models/models.py +26 -0
- sdk/models/onboarding.py +323 -0
- sdk/models/orgs.py +11 -0
- sdk/models/pipelines.py +147 -0
- sdk/models/projects.py +19 -0
- sdk/models/search.py +149 -0
- sdk/models/training.py +57 -0
- sdk/models/usage.py +39 -0
- sdk/namespaces.py +386 -0
- sdk/py.typed +0 -0
- sdk/resources/__init__.py +45 -0
- sdk/resources/_mixin_base.py +40 -0
- sdk/resources/a2a.py +230 -0
- sdk/resources/agents.py +487 -0
- sdk/resources/audit.py +144 -0
- sdk/resources/auth.py +138 -0
- sdk/resources/console.py +411 -0
- sdk/resources/corpora.py +269 -0
- sdk/resources/deployments.py +105 -0
- sdk/resources/documents.py +597 -0
- sdk/resources/feeds.py +246 -0
- sdk/resources/indexes.py +210 -0
- sdk/resources/jobs.py +164 -0
- sdk/resources/metadata.py +53 -0
- sdk/resources/models.py +99 -0
- sdk/resources/onboarding.py +542 -0
- sdk/resources/orgs.py +35 -0
- sdk/resources/pipeline_builder.py +257 -0
- sdk/resources/pipelines.py +520 -0
- sdk/resources/projects.py +87 -0
- sdk/resources/search.py +277 -0
- sdk/resources/training.py +358 -0
- sdk/resources/usage.py +92 -0
- sdk/types/__init__.py +366 -0
- sdk/types/a2a.py +88 -0
- sdk/types/agents.py +133 -0
- sdk/types/audit.py +26 -0
- sdk/types/auth.py +45 -0
- sdk/types/chunks.py +18 -0
- sdk/types/common.py +10 -0
- sdk/types/console.py +99 -0
- sdk/types/corpora.py +42 -0
- sdk/types/deployments.py +11 -0
- sdk/types/documents.py +104 -0
- sdk/types/embeddings.py +22 -0
- sdk/types/evaluation.py +15 -0
- sdk/types/feedback.py +7 -0
- sdk/types/feeds.py +61 -0
- sdk/types/indexes.py +30 -0
- sdk/types/jobs.py +50 -0
- sdk/types/models.py +22 -0
- sdk/types/onboarding.py +395 -0
- sdk/types/orgs.py +9 -0
- sdk/types/pipelines.py +177 -0
- sdk/types/projects.py +14 -0
- sdk/types/search.py +116 -0
- sdk/types/training.py +55 -0
- sdk/types/usage.py +37 -0
sdk/models/usage.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Pydantic models for usage types."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from sdk.models._base import K2BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UsageSeriesPointModel(K2BaseModel):
|
|
9
|
+
date: str
|
|
10
|
+
count: int
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class UsageSummaryResponseModel(K2BaseModel):
|
|
14
|
+
range: str | None = None
|
|
15
|
+
total_requests: int | None = None
|
|
16
|
+
daily: list[UsageSeriesPointModel] | None = None
|
|
17
|
+
latency_p50_ms: float | None = None
|
|
18
|
+
latency_p95_ms: float | None = None
|
|
19
|
+
error_rate: float | None = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class UsageByCorpusItemModel(K2BaseModel):
|
|
23
|
+
corpus_id: str | None = None
|
|
24
|
+
corpus_name: str | None = None
|
|
25
|
+
requests: int | None = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class UsageByCorpusResponseModel(K2BaseModel):
|
|
29
|
+
items: list[UsageByCorpusItemModel]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UsageByKeyItemModel(K2BaseModel):
|
|
33
|
+
key_id: str | None = None
|
|
34
|
+
name: str | None = None
|
|
35
|
+
requests: int | None = None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class UsageByKeyResponseModel(K2BaseModel):
|
|
39
|
+
items: list[UsageByKeyItemModel]
|
sdk/namespaces.py
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"""Sub-client namespace accessors for the Knowledge2 SDK.
|
|
2
|
+
|
|
3
|
+
Lightweight proxy objects that group related methods into discoverable
|
|
4
|
+
namespaces without changing the existing flat API::
|
|
5
|
+
|
|
6
|
+
# Flat (existing, unchanged)
|
|
7
|
+
client.upload_document(corpus_id, file_path="doc.pdf")
|
|
8
|
+
|
|
9
|
+
# Namespaced (new, equivalent)
|
|
10
|
+
client.documents.upload(corpus_id, file_path="doc.pdf")
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import TYPE_CHECKING, Any
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from sdk._paging import Page, SyncPager
|
|
19
|
+
from sdk.client import Knowledge2
|
|
20
|
+
from sdk.types import (
|
|
21
|
+
ApiKeyCreateResponse,
|
|
22
|
+
ApiKeyListResponse,
|
|
23
|
+
ApiKeyRevokeResponse,
|
|
24
|
+
ApiKeyRotateResponse,
|
|
25
|
+
ChunkingConfig,
|
|
26
|
+
CorpusDeleteResponse,
|
|
27
|
+
CorpusResponse,
|
|
28
|
+
CorpusStatusResponse,
|
|
29
|
+
DeploymentResponse,
|
|
30
|
+
DocumentBatchUploadResponse,
|
|
31
|
+
DocumentCreateResponse,
|
|
32
|
+
DocumentDeleteResponse,
|
|
33
|
+
DocumentDetailResponse,
|
|
34
|
+
DocumentManifestIngestResponse,
|
|
35
|
+
DocumentUrlIngestResponse,
|
|
36
|
+
EmbeddingsResponse,
|
|
37
|
+
FeedbackResponse,
|
|
38
|
+
JobResponse,
|
|
39
|
+
JobStatusResponse,
|
|
40
|
+
ModelDeleteResponse,
|
|
41
|
+
ReconcileJobsResponse,
|
|
42
|
+
SearchBatchResponse,
|
|
43
|
+
SearchGenerateResponse,
|
|
44
|
+
SearchResponse,
|
|
45
|
+
TuningRunDetailResponse,
|
|
46
|
+
TuningRunLogsResponse,
|
|
47
|
+
TuningRunResponse,
|
|
48
|
+
WhoAmIResponse,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class _Namespace:
|
|
53
|
+
"""Base class for namespace proxies."""
|
|
54
|
+
|
|
55
|
+
__slots__ = ("_client",)
|
|
56
|
+
|
|
57
|
+
def __init__(self, client: Knowledge2) -> None:
|
|
58
|
+
self._client = client
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ------------------------------------------------------------------
|
|
62
|
+
# Documents
|
|
63
|
+
# ------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class DocumentsNamespace(_Namespace):
|
|
67
|
+
"""Document operations: ``client.documents.*``"""
|
|
68
|
+
|
|
69
|
+
def upload(
|
|
70
|
+
self,
|
|
71
|
+
corpus_id: str,
|
|
72
|
+
*,
|
|
73
|
+
file_path: str | None = None,
|
|
74
|
+
file_bytes: bytes | None = None,
|
|
75
|
+
filename: str | None = None,
|
|
76
|
+
raw_text: str | None = None,
|
|
77
|
+
source_uri: str | None = None,
|
|
78
|
+
metadata: dict[str, Any] | None = None,
|
|
79
|
+
auto_index: bool | None = None,
|
|
80
|
+
chunk_strategy: str | None = None,
|
|
81
|
+
chunking: ChunkingConfig | None = None,
|
|
82
|
+
idempotency_key: str | None = None,
|
|
83
|
+
) -> DocumentCreateResponse:
|
|
84
|
+
return self._client.upload_document(
|
|
85
|
+
corpus_id,
|
|
86
|
+
file_path=file_path,
|
|
87
|
+
file_bytes=file_bytes,
|
|
88
|
+
filename=filename,
|
|
89
|
+
raw_text=raw_text,
|
|
90
|
+
source_uri=source_uri,
|
|
91
|
+
metadata=metadata,
|
|
92
|
+
auto_index=auto_index,
|
|
93
|
+
chunk_strategy=chunk_strategy,
|
|
94
|
+
chunking=chunking,
|
|
95
|
+
idempotency_key=idempotency_key,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def upload_batch(
|
|
99
|
+
self,
|
|
100
|
+
corpus_id: str,
|
|
101
|
+
documents: list[dict[str, Any]],
|
|
102
|
+
idempotency_key: str | None = None,
|
|
103
|
+
**kwargs: Any,
|
|
104
|
+
) -> DocumentBatchUploadResponse:
|
|
105
|
+
return self._client.upload_documents_batch(corpus_id, documents, idempotency_key, **kwargs)
|
|
106
|
+
|
|
107
|
+
def upload_files_batch(
|
|
108
|
+
self,
|
|
109
|
+
corpus_id: str,
|
|
110
|
+
files: list[tuple[str, bytes]],
|
|
111
|
+
idempotency_key: str | None = None,
|
|
112
|
+
**kwargs: Any,
|
|
113
|
+
) -> DocumentBatchUploadResponse:
|
|
114
|
+
return self._client.upload_files_batch(corpus_id, files, idempotency_key, **kwargs)
|
|
115
|
+
|
|
116
|
+
def upload_parallel(
|
|
117
|
+
self,
|
|
118
|
+
corpus_id: str,
|
|
119
|
+
file_paths: list[str],
|
|
120
|
+
**kwargs: Any,
|
|
121
|
+
) -> list[DocumentCreateResponse]:
|
|
122
|
+
return self._client.upload_documents_parallel(corpus_id, file_paths, **kwargs)
|
|
123
|
+
|
|
124
|
+
def ingest_urls(
|
|
125
|
+
self,
|
|
126
|
+
corpus_id: str,
|
|
127
|
+
urls: list[dict[str, Any]],
|
|
128
|
+
idempotency_key: str | None = None,
|
|
129
|
+
**kwargs: Any,
|
|
130
|
+
) -> DocumentUrlIngestResponse:
|
|
131
|
+
return self._client.ingest_urls(corpus_id, urls, idempotency_key, **kwargs)
|
|
132
|
+
|
|
133
|
+
def ingest_manifest(
|
|
134
|
+
self,
|
|
135
|
+
corpus_id: str,
|
|
136
|
+
manifest_uri: str,
|
|
137
|
+
max_documents: int | None = None,
|
|
138
|
+
idempotency_key: str | None = None,
|
|
139
|
+
**kwargs: Any,
|
|
140
|
+
) -> DocumentManifestIngestResponse:
|
|
141
|
+
return self._client.ingest_manifest(
|
|
142
|
+
corpus_id, manifest_uri, max_documents, idempotency_key, **kwargs
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
def list(self, corpus_id: str, **kwargs: Any) -> Page[dict[str, Any]]:
|
|
146
|
+
return self._client.list_documents(corpus_id, **kwargs)
|
|
147
|
+
|
|
148
|
+
def iter(self, corpus_id: str, **kwargs: Any) -> SyncPager[dict[str, Any]]:
|
|
149
|
+
return self._client.iter_documents(corpus_id, **kwargs)
|
|
150
|
+
|
|
151
|
+
def get(self, doc_id: str) -> DocumentDetailResponse:
|
|
152
|
+
return self._client.get_document(doc_id)
|
|
153
|
+
|
|
154
|
+
def update_metadata(self, doc_id: str, metadata: dict[str, Any]) -> dict[str, Any]:
|
|
155
|
+
return self._client.update_document_metadata(doc_id, metadata)
|
|
156
|
+
|
|
157
|
+
def delete(
|
|
158
|
+
self, corpus_id: str, doc_id: str, *, confirm: bool = False, reindex: bool = False
|
|
159
|
+
) -> DocumentDeleteResponse:
|
|
160
|
+
return self._client.delete_document(corpus_id, doc_id, confirm=confirm, reindex=reindex)
|
|
161
|
+
|
|
162
|
+
def list_chunks(
|
|
163
|
+
self, corpus_id: str, limit: int = 100, offset: int = 0
|
|
164
|
+
) -> Page[dict[str, Any]]:
|
|
165
|
+
return self._client.list_chunks(corpus_id, limit=limit, offset=offset)
|
|
166
|
+
|
|
167
|
+
def iter_chunks(self, corpus_id: str, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
168
|
+
return self._client.iter_chunks(corpus_id, limit=limit)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# ------------------------------------------------------------------
|
|
172
|
+
# Corpora
|
|
173
|
+
# ------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class CorporaNamespace(_Namespace):
|
|
177
|
+
"""Corpus operations: ``client.corpora.*``"""
|
|
178
|
+
|
|
179
|
+
def create(self, project_id: str, name: str, description: str | None = None) -> CorpusResponse:
|
|
180
|
+
return self._client.create_corpus(project_id, name, description)
|
|
181
|
+
|
|
182
|
+
def list(self, limit: int = 100, offset: int = 0) -> Page[dict[str, Any]]:
|
|
183
|
+
return self._client.list_corpora(limit=limit, offset=offset)
|
|
184
|
+
|
|
185
|
+
def iter(self, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
186
|
+
return self._client.iter_corpora(limit=limit)
|
|
187
|
+
|
|
188
|
+
def get(self, corpus_id: str) -> CorpusResponse:
|
|
189
|
+
return self._client.get_corpus(corpus_id)
|
|
190
|
+
|
|
191
|
+
def status(self, corpus_id: str) -> CorpusStatusResponse:
|
|
192
|
+
return self._client.get_corpus_status(corpus_id)
|
|
193
|
+
|
|
194
|
+
def update(self, corpus_id: str, **kwargs: Any) -> CorpusResponse:
|
|
195
|
+
return self._client.update_corpus(corpus_id, **kwargs)
|
|
196
|
+
|
|
197
|
+
def delete(
|
|
198
|
+
self, corpus_id: str, *, confirm: bool = False, force: bool = False
|
|
199
|
+
) -> CorpusDeleteResponse:
|
|
200
|
+
return self._client.delete_corpus(corpus_id, confirm=confirm, force=force)
|
|
201
|
+
|
|
202
|
+
def list_models(
|
|
203
|
+
self, corpus_id: str, limit: int = 100, offset: int = 0
|
|
204
|
+
) -> Page[dict[str, Any]]:
|
|
205
|
+
return self._client.list_corpus_models(corpus_id, limit=limit, offset=offset)
|
|
206
|
+
|
|
207
|
+
def iter_models(self, corpus_id: str, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
208
|
+
return self._client.iter_corpus_models(corpus_id, limit=limit)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
# ------------------------------------------------------------------
|
|
212
|
+
# Search
|
|
213
|
+
# ------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class SearchNamespace(_Namespace):
|
|
217
|
+
"""Search operations: ``client.search_ns.*``"""
|
|
218
|
+
|
|
219
|
+
def query(self, corpus_id: str, query: str, **kwargs: Any) -> SearchResponse:
|
|
220
|
+
return self._client.search(corpus_id, query, **kwargs)
|
|
221
|
+
|
|
222
|
+
def batch(self, corpus_id: str, queries: list[str], **kwargs: Any) -> SearchBatchResponse:
|
|
223
|
+
return self._client.search_batch(corpus_id, queries, **kwargs)
|
|
224
|
+
|
|
225
|
+
def generate(self, corpus_id: str, query: str, **kwargs: Any) -> SearchGenerateResponse:
|
|
226
|
+
return self._client.search_generate(corpus_id, query, **kwargs)
|
|
227
|
+
|
|
228
|
+
def embeddings(
|
|
229
|
+
self, model: str, inputs: list[str], embed_type: str = "query"
|
|
230
|
+
) -> EmbeddingsResponse:
|
|
231
|
+
return self._client.embeddings(model, inputs, embed_type)
|
|
232
|
+
|
|
233
|
+
def feedback(self, corpus_id: str, query: str, **kwargs: Any) -> FeedbackResponse:
|
|
234
|
+
return self._client.create_feedback(corpus_id, query, **kwargs)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
# ------------------------------------------------------------------
|
|
238
|
+
# Models
|
|
239
|
+
# ------------------------------------------------------------------
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class ModelsNamespace(_Namespace):
|
|
243
|
+
"""Model operations: ``client.models_ns.*``"""
|
|
244
|
+
|
|
245
|
+
def list(self, limit: int = 100, offset: int = 0) -> Page[dict[str, Any]]:
|
|
246
|
+
return self._client.list_models(limit=limit, offset=offset)
|
|
247
|
+
|
|
248
|
+
def iter(self, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
249
|
+
return self._client.iter_models(limit=limit)
|
|
250
|
+
|
|
251
|
+
def delete(
|
|
252
|
+
self, model_id: str, *, confirm: bool = False, force: bool = False
|
|
253
|
+
) -> ModelDeleteResponse:
|
|
254
|
+
return self._client.delete_model(model_id, confirm=confirm, force=force)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
# ------------------------------------------------------------------
|
|
258
|
+
# Jobs
|
|
259
|
+
# ------------------------------------------------------------------
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class JobsNamespace(_Namespace):
|
|
263
|
+
"""Job operations: ``client.jobs.*``"""
|
|
264
|
+
|
|
265
|
+
def get(self, job_id: str) -> JobResponse:
|
|
266
|
+
return self._client.get_job(job_id)
|
|
267
|
+
|
|
268
|
+
def list(self, **kwargs: Any) -> Page[dict[str, Any]]:
|
|
269
|
+
return self._client.list_jobs(**kwargs)
|
|
270
|
+
|
|
271
|
+
def iter(self, **kwargs: Any) -> SyncPager[dict[str, Any]]:
|
|
272
|
+
return self._client.iter_jobs(**kwargs)
|
|
273
|
+
|
|
274
|
+
def cancel(self, job_id: str) -> JobStatusResponse:
|
|
275
|
+
return self._client.cancel_job(job_id)
|
|
276
|
+
|
|
277
|
+
def retry(self, job_id: str) -> JobStatusResponse:
|
|
278
|
+
return self._client.retry_job(job_id)
|
|
279
|
+
|
|
280
|
+
def reconcile(self) -> ReconcileJobsResponse:
|
|
281
|
+
return self._client.reconcile_jobs()
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
# ------------------------------------------------------------------
|
|
285
|
+
# Training
|
|
286
|
+
# ------------------------------------------------------------------
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class TrainingNamespace(_Namespace):
|
|
290
|
+
"""Training operations: ``client.training_ns.*``"""
|
|
291
|
+
|
|
292
|
+
def build_data(self, corpus_id: str, idempotency_key: str | None = None) -> Any:
|
|
293
|
+
return self._client.build_training_data(corpus_id, idempotency_key)
|
|
294
|
+
|
|
295
|
+
def list_data(self, corpus_id: str, limit: int = 100, offset: int = 0) -> Page[dict[str, Any]]:
|
|
296
|
+
return self._client.list_training_data(corpus_id, limit=limit, offset=offset)
|
|
297
|
+
|
|
298
|
+
def iter_data(self, corpus_id: str, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
299
|
+
return self._client.iter_training_data(corpus_id, limit=limit)
|
|
300
|
+
|
|
301
|
+
def list_runs(self, corpus_id: str, limit: int = 100, offset: int = 0) -> Page[dict[str, Any]]:
|
|
302
|
+
return self._client.list_tuning_runs(corpus_id, limit=limit, offset=offset)
|
|
303
|
+
|
|
304
|
+
def iter_runs(self, corpus_id: str, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
305
|
+
return self._client.iter_tuning_runs(corpus_id, limit=limit)
|
|
306
|
+
|
|
307
|
+
def create_run(
|
|
308
|
+
self, corpus_id: str, idempotency_key: str | None = None, **kwargs: Any
|
|
309
|
+
) -> TuningRunResponse:
|
|
310
|
+
return self._client.create_tuning_run(corpus_id, idempotency_key, **kwargs)
|
|
311
|
+
|
|
312
|
+
def build_and_start(
|
|
313
|
+
self, corpus_id: str, idempotency_key: str | None = None, **kwargs: Any
|
|
314
|
+
) -> Any:
|
|
315
|
+
return self._client.build_and_start_tuning_run(corpus_id, idempotency_key, **kwargs)
|
|
316
|
+
|
|
317
|
+
def get_run(self, run_id: str) -> TuningRunDetailResponse:
|
|
318
|
+
return self._client.get_tuning_run(run_id)
|
|
319
|
+
|
|
320
|
+
def get_run_logs(self, run_id: str, tail: int = 200) -> TuningRunLogsResponse:
|
|
321
|
+
return self._client.get_tuning_run_logs(run_id, tail)
|
|
322
|
+
|
|
323
|
+
def cancel_run(self, run_id: str) -> Any:
|
|
324
|
+
return self._client.cancel_tuning_run(run_id)
|
|
325
|
+
|
|
326
|
+
def promote_run(self, run_id: str) -> Any:
|
|
327
|
+
return self._client.promote_tuning_run(run_id)
|
|
328
|
+
|
|
329
|
+
def get_eval(self, eval_id: str) -> Any:
|
|
330
|
+
return self._client.get_eval_run(eval_id)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
# ------------------------------------------------------------------
|
|
334
|
+
# Deployments
|
|
335
|
+
# ------------------------------------------------------------------
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class DeploymentsNamespace(_Namespace):
|
|
339
|
+
"""Deployment operations: ``client.deployments.*``"""
|
|
340
|
+
|
|
341
|
+
def create(
|
|
342
|
+
self,
|
|
343
|
+
corpus_id: str,
|
|
344
|
+
model_id: str,
|
|
345
|
+
*,
|
|
346
|
+
traffic_pct: int = 100,
|
|
347
|
+
reindex: bool = True,
|
|
348
|
+
) -> DeploymentResponse:
|
|
349
|
+
return self._client.create_deployment(
|
|
350
|
+
corpus_id, model_id, traffic_pct=traffic_pct, reindex=reindex
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def list(self, corpus_id: str, limit: int = 100, offset: int = 0) -> Page[dict[str, Any]]:
|
|
354
|
+
return self._client.list_deployments(corpus_id, limit=limit, offset=offset)
|
|
355
|
+
|
|
356
|
+
def iter(self, corpus_id: str, *, limit: int = 100) -> SyncPager[dict[str, Any]]:
|
|
357
|
+
return self._client.iter_deployments(corpus_id, limit=limit)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
# ------------------------------------------------------------------
|
|
361
|
+
# Auth
|
|
362
|
+
# ------------------------------------------------------------------
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class AuthNamespace(_Namespace):
|
|
366
|
+
"""Auth operations: ``client.auth.*``"""
|
|
367
|
+
|
|
368
|
+
def create_api_key(
|
|
369
|
+
self,
|
|
370
|
+
org_id: str,
|
|
371
|
+
name: str,
|
|
372
|
+
scopes: dict[str, Any] | None = None,
|
|
373
|
+
) -> ApiKeyCreateResponse:
|
|
374
|
+
return self._client.create_api_key(org_id, name, scopes)
|
|
375
|
+
|
|
376
|
+
def list_api_keys(self) -> ApiKeyListResponse:
|
|
377
|
+
return self._client.list_api_keys()
|
|
378
|
+
|
|
379
|
+
def revoke_api_key(self, key_id: str) -> ApiKeyRevokeResponse:
|
|
380
|
+
return self._client.revoke_api_key(key_id)
|
|
381
|
+
|
|
382
|
+
def rotate_api_key(self, key_id: str) -> ApiKeyRotateResponse:
|
|
383
|
+
return self._client.rotate_api_key(key_id)
|
|
384
|
+
|
|
385
|
+
def whoami(self) -> WhoAmIResponse:
|
|
386
|
+
return self._client.get_whoami()
|
sdk/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .a2a import A2AMixin
|
|
4
|
+
from .agents import AgentsMixin
|
|
5
|
+
from .audit import AuditMixin
|
|
6
|
+
from .auth import AuthMixin
|
|
7
|
+
from .console import ConsoleMixin
|
|
8
|
+
from .corpora import CorporaMixin
|
|
9
|
+
from .deployments import DeploymentsMixin
|
|
10
|
+
from .documents import DocumentsMixin
|
|
11
|
+
from .feeds import FeedsMixin
|
|
12
|
+
from .indexes import IndexesMixin
|
|
13
|
+
from .jobs import JobsMixin
|
|
14
|
+
from .metadata import MetadataMixin
|
|
15
|
+
from .models import ModelsMixin
|
|
16
|
+
from .onboarding import OnboardingMixin
|
|
17
|
+
from .orgs import OrgsMixin
|
|
18
|
+
from .pipelines import PipelinesMixin
|
|
19
|
+
from .projects import ProjectsMixin
|
|
20
|
+
from .search import SearchMixin
|
|
21
|
+
from .training import TrainingMixin
|
|
22
|
+
from .usage import UsageMixin
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"A2AMixin",
|
|
26
|
+
"AgentsMixin",
|
|
27
|
+
"AuditMixin",
|
|
28
|
+
"AuthMixin",
|
|
29
|
+
"ConsoleMixin",
|
|
30
|
+
"CorporaMixin",
|
|
31
|
+
"DeploymentsMixin",
|
|
32
|
+
"DocumentsMixin",
|
|
33
|
+
"FeedsMixin",
|
|
34
|
+
"IndexesMixin",
|
|
35
|
+
"JobsMixin",
|
|
36
|
+
"MetadataMixin",
|
|
37
|
+
"ModelsMixin",
|
|
38
|
+
"OnboardingMixin",
|
|
39
|
+
"OrgsMixin",
|
|
40
|
+
"PipelinesMixin",
|
|
41
|
+
"ProjectsMixin",
|
|
42
|
+
"SearchMixin",
|
|
43
|
+
"TrainingMixin",
|
|
44
|
+
"UsageMixin",
|
|
45
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Protocol, runtime_checkable
|
|
4
|
+
|
|
5
|
+
from sdk._paging import Page, SyncPager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@runtime_checkable
|
|
9
|
+
class RequesterMixin(Protocol):
|
|
10
|
+
def _request(self, method: str, path: str, **kwargs: Any) -> Any: ...
|
|
11
|
+
|
|
12
|
+
def _maybe_validate(self, data: Any, model_name: str) -> Any: ...
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def _idempotency_headers(idempotency_key: str | None) -> dict[str, str]: ...
|
|
16
|
+
|
|
17
|
+
def _wait_for_job(
|
|
18
|
+
self, job_id: str, *, poll_s: int = 5, timeout_s: float | None = None
|
|
19
|
+
) -> dict[str, Any]: ...
|
|
20
|
+
|
|
21
|
+
def _list_page(
|
|
22
|
+
self,
|
|
23
|
+
method: str,
|
|
24
|
+
path: str,
|
|
25
|
+
*,
|
|
26
|
+
items_key: str,
|
|
27
|
+
params: dict[str, Any] | None = None,
|
|
28
|
+
limit: int = 100,
|
|
29
|
+
offset: int = 0,
|
|
30
|
+
) -> Page[dict[str, Any]]: ...
|
|
31
|
+
|
|
32
|
+
def _paginate(
|
|
33
|
+
self,
|
|
34
|
+
method: str,
|
|
35
|
+
path: str,
|
|
36
|
+
*,
|
|
37
|
+
items_key: str,
|
|
38
|
+
params: dict[str, Any] | None = None,
|
|
39
|
+
limit: int = 100,
|
|
40
|
+
) -> SyncPager[dict[str, Any]]: ...
|