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/types/onboarding.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"""SDK types for dataset onboarding."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
try: # Python 3.11+
|
|
6
|
+
from typing import NotRequired, TypedDict
|
|
7
|
+
except ImportError: # pragma: no cover - Python < 3.11
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
# =============================================================================
|
|
11
|
+
# Gold Labels
|
|
12
|
+
# =============================================================================
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GoldLabelDocumentReference(TypedDict, total=False):
|
|
16
|
+
"""Reference to a document for gold label resolution."""
|
|
17
|
+
|
|
18
|
+
type: str # "filename" | "document_id" | "text_match"
|
|
19
|
+
value: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class GoldLabelChunkReference(TypedDict, total=False):
|
|
23
|
+
"""Reference to a chunk within a document."""
|
|
24
|
+
|
|
25
|
+
type: str # "line_range" | "text_excerpt" | "chunk_index" | "offset_range"
|
|
26
|
+
value: str | int | dict
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class GoldLabelEntry(TypedDict, total=False):
|
|
30
|
+
"""A single gold label entry (query-chunk pair)."""
|
|
31
|
+
|
|
32
|
+
query: str
|
|
33
|
+
document_reference: NotRequired[GoldLabelDocumentReference]
|
|
34
|
+
chunk_reference: NotRequired[GoldLabelChunkReference]
|
|
35
|
+
relevant_text: NotRequired[str]
|
|
36
|
+
metadata: NotRequired[dict]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class GoldLabelsUploadRequest(TypedDict, total=False):
|
|
40
|
+
"""Request to upload gold labels for a corpus."""
|
|
41
|
+
|
|
42
|
+
labels: list[GoldLabelEntry]
|
|
43
|
+
description: NotRequired[str]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ResolvedLabelInfo(TypedDict):
|
|
47
|
+
"""Information about a resolved gold label."""
|
|
48
|
+
|
|
49
|
+
label_id: str
|
|
50
|
+
query: str
|
|
51
|
+
chunk_id: str | None
|
|
52
|
+
document_id: str | None
|
|
53
|
+
confidence: float
|
|
54
|
+
resolution_method: str
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class GoldLabelsUploadResponse(TypedDict):
|
|
58
|
+
"""Response after uploading gold labels."""
|
|
59
|
+
|
|
60
|
+
corpus_id: str
|
|
61
|
+
total_uploaded: int
|
|
62
|
+
resolved_count: int
|
|
63
|
+
unmatched_count: int
|
|
64
|
+
labels: list[ResolvedLabelInfo]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class GoldLabelListItem(TypedDict):
|
|
68
|
+
"""Gold label item for listing."""
|
|
69
|
+
|
|
70
|
+
id: str
|
|
71
|
+
query: str
|
|
72
|
+
chunk_id: str | None
|
|
73
|
+
document_id: str | None
|
|
74
|
+
source: str | None
|
|
75
|
+
confidence: float | None
|
|
76
|
+
created_at: str
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class GoldLabelsListResponse(TypedDict):
|
|
80
|
+
"""Response listing gold labels for a corpus."""
|
|
81
|
+
|
|
82
|
+
corpus_id: str
|
|
83
|
+
total: int
|
|
84
|
+
labels: list[GoldLabelListItem]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# =============================================================================
|
|
88
|
+
# Dataset Analysis
|
|
89
|
+
# =============================================================================
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class DatasetAnalysisRequest(TypedDict, total=False):
|
|
93
|
+
"""Request to start dataset analysis pipeline."""
|
|
94
|
+
|
|
95
|
+
description: NotRequired[str]
|
|
96
|
+
auto_bootstrap: NotRequired[bool]
|
|
97
|
+
bootstrap_num_samples: NotRequired[int]
|
|
98
|
+
queries_per_chunk: NotRequired[int]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class DatasetAnalysisResponse(TypedDict):
|
|
102
|
+
"""Response after starting dataset analysis."""
|
|
103
|
+
|
|
104
|
+
analysis_id: str
|
|
105
|
+
corpus_id: str
|
|
106
|
+
status: str
|
|
107
|
+
job_id: str | None
|
|
108
|
+
estimated_duration_seconds: int | None
|
|
109
|
+
created_at: str
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class DatasetAnalysisSummary(TypedDict):
|
|
113
|
+
"""Summary of a dataset analysis run."""
|
|
114
|
+
|
|
115
|
+
analysis_id: str
|
|
116
|
+
status: str
|
|
117
|
+
current_stage: str | None
|
|
118
|
+
stages_completed: list[str]
|
|
119
|
+
has_prompt: bool
|
|
120
|
+
has_evaluation: bool
|
|
121
|
+
bootstrap_enabled: bool
|
|
122
|
+
bootstrap_labels_count: int | None
|
|
123
|
+
documents_at_analysis: int | None
|
|
124
|
+
started_at: str
|
|
125
|
+
created_at: str
|
|
126
|
+
completed_at: str | None
|
|
127
|
+
error_message: str | None
|
|
128
|
+
domain: str | None
|
|
129
|
+
lexical_strategy: str | None
|
|
130
|
+
quality_score: float | None
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class OnboardingStatusResponse(TypedDict):
|
|
134
|
+
"""Response showing onboarding status for a corpus."""
|
|
135
|
+
|
|
136
|
+
corpus_id: str
|
|
137
|
+
latest_analysis: DatasetAnalysisSummary | None
|
|
138
|
+
gold_labels_count: int
|
|
139
|
+
synthetic_batches_count: int
|
|
140
|
+
has_summaries: bool
|
|
141
|
+
analysis_stale: bool
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class SearcherPersona(TypedDict):
|
|
145
|
+
"""Searcher persona from Stage 1 analysis."""
|
|
146
|
+
|
|
147
|
+
who: str
|
|
148
|
+
goal: str
|
|
149
|
+
knowledge_state: str
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class LexicalStrategy(TypedDict):
|
|
153
|
+
"""Lexical strategy recommendation."""
|
|
154
|
+
|
|
155
|
+
recommendation: str
|
|
156
|
+
rationale: str
|
|
157
|
+
techniques: list[str]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class DatasetAnalysisDetails(TypedDict):
|
|
161
|
+
"""Detailed results of a dataset analysis run."""
|
|
162
|
+
|
|
163
|
+
analysis_id: str
|
|
164
|
+
corpus_id: str
|
|
165
|
+
status: str
|
|
166
|
+
created_at: str
|
|
167
|
+
completed_at: str | None
|
|
168
|
+
config: dict
|
|
169
|
+
schema_analysis: dict | None
|
|
170
|
+
domain: str | None
|
|
171
|
+
expertise_level: str | None
|
|
172
|
+
data_relationship: str | None
|
|
173
|
+
searcher_persona: SearcherPersona | None
|
|
174
|
+
lexical_strategy: LexicalStrategy | None
|
|
175
|
+
stage1_analysis: dict | None
|
|
176
|
+
artifact_uri: str | None
|
|
177
|
+
prompt_uri: str | None
|
|
178
|
+
bootstrap_enabled: bool
|
|
179
|
+
bootstrap_labels_count: int | None
|
|
180
|
+
error_message: str | None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# =============================================================================
|
|
184
|
+
# Synthetic Query Generation
|
|
185
|
+
# =============================================================================
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class SyntheticQueryGenerationRequest(TypedDict, total=False):
|
|
189
|
+
"""Request to generate synthetic queries."""
|
|
190
|
+
|
|
191
|
+
analysis_id: str
|
|
192
|
+
sample_size: NotRequired[int]
|
|
193
|
+
queries_per_chunk: NotRequired[int]
|
|
194
|
+
use_document_context: NotRequired[bool]
|
|
195
|
+
eval_sample_size: NotRequired[int]
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class SyntheticQueryBatchResponse(TypedDict):
|
|
199
|
+
"""Response after starting synthetic query generation."""
|
|
200
|
+
|
|
201
|
+
batch_id: str
|
|
202
|
+
corpus_id: str
|
|
203
|
+
analysis_id: str
|
|
204
|
+
status: str
|
|
205
|
+
job_id: str | None
|
|
206
|
+
sample_size: int | None
|
|
207
|
+
queries_per_chunk: int
|
|
208
|
+
estimated_queries: int | None
|
|
209
|
+
created_at: str
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class SyntheticQueryBatchSummary(TypedDict):
|
|
213
|
+
"""Summary of a synthetic query batch."""
|
|
214
|
+
|
|
215
|
+
batch_id: str
|
|
216
|
+
status: str
|
|
217
|
+
sample_size: int | None
|
|
218
|
+
queries_per_chunk: int
|
|
219
|
+
total_chunks_processed: int | None
|
|
220
|
+
total_queries_generated: int | None
|
|
221
|
+
created_at: str
|
|
222
|
+
completed_at: str | None
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class SyntheticQueryBatchListResponse(TypedDict):
|
|
226
|
+
"""Response listing synthetic query batches."""
|
|
227
|
+
|
|
228
|
+
corpus_id: str
|
|
229
|
+
batches: list[SyntheticQueryBatchSummary]
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class SyntheticQuerySample(TypedDict):
|
|
233
|
+
"""Sample synthetic query for preview."""
|
|
234
|
+
|
|
235
|
+
chunk_id: str
|
|
236
|
+
chunk_text_preview: str
|
|
237
|
+
queries: list[str]
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class SyntheticQueryBatchDetails(TypedDict):
|
|
241
|
+
"""Detailed information about a synthetic query batch."""
|
|
242
|
+
|
|
243
|
+
batch_id: str
|
|
244
|
+
corpus_id: str
|
|
245
|
+
analysis_id: str
|
|
246
|
+
status: str
|
|
247
|
+
created_at: str
|
|
248
|
+
completed_at: str | None
|
|
249
|
+
sample_size: int | None
|
|
250
|
+
queries_per_chunk: int
|
|
251
|
+
use_document_context: bool
|
|
252
|
+
config: dict
|
|
253
|
+
total_chunks_processed: int | None
|
|
254
|
+
total_queries_generated: int | None
|
|
255
|
+
stats: dict
|
|
256
|
+
artifact_uri: str | None
|
|
257
|
+
sample_queries: list[SyntheticQuerySample]
|
|
258
|
+
error_message: str | None
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# =============================================================================
|
|
262
|
+
# Evaluation
|
|
263
|
+
# =============================================================================
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class EvaluationRequest(TypedDict, total=False):
|
|
267
|
+
"""Request to evaluate synthetic queries."""
|
|
268
|
+
|
|
269
|
+
batch_id: str
|
|
270
|
+
sample_size: NotRequired[int]
|
|
271
|
+
generate_report: NotRequired[bool]
|
|
272
|
+
report_formats: NotRequired[list[str]]
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class EvaluationResponse(TypedDict):
|
|
276
|
+
"""Response after starting evaluation."""
|
|
277
|
+
|
|
278
|
+
eval_id: str
|
|
279
|
+
corpus_id: str
|
|
280
|
+
batch_id: str
|
|
281
|
+
status: str
|
|
282
|
+
job_id: str | None
|
|
283
|
+
created_at: str
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class EvaluationMetrics(TypedDict, total=False):
|
|
287
|
+
"""Aggregated evaluation metrics.
|
|
288
|
+
|
|
289
|
+
Scale contract:
|
|
290
|
+
- avg_relevance / avg_groundedness / avg_style: 0-10
|
|
291
|
+
- avg_lexical_diversity / pass_rate: 0-1
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
total_evaluated: int
|
|
295
|
+
avg_relevance: NotRequired[float]
|
|
296
|
+
avg_groundedness: NotRequired[float]
|
|
297
|
+
avg_style: NotRequired[float]
|
|
298
|
+
avg_lexical_diversity: NotRequired[float]
|
|
299
|
+
pass_rate: NotRequired[float]
|
|
300
|
+
score_distribution: NotRequired[dict]
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
class EvaluationSummary(TypedDict):
|
|
304
|
+
"""Summary of an evaluation run."""
|
|
305
|
+
|
|
306
|
+
eval_id: str
|
|
307
|
+
batch_id: str
|
|
308
|
+
status: str
|
|
309
|
+
sample_size: int | None
|
|
310
|
+
metrics: EvaluationMetrics | None
|
|
311
|
+
created_at: str
|
|
312
|
+
completed_at: str | None
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class EvaluationListResponse(TypedDict):
|
|
316
|
+
"""Response listing evaluations for a corpus."""
|
|
317
|
+
|
|
318
|
+
corpus_id: str
|
|
319
|
+
evaluations: list[EvaluationSummary]
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class EvaluationDetails(TypedDict):
|
|
323
|
+
"""Detailed evaluation results."""
|
|
324
|
+
|
|
325
|
+
eval_id: str
|
|
326
|
+
corpus_id: str
|
|
327
|
+
batch_id: str
|
|
328
|
+
status: str
|
|
329
|
+
created_at: str
|
|
330
|
+
completed_at: str | None
|
|
331
|
+
sample_size: int | None
|
|
332
|
+
config: dict
|
|
333
|
+
metrics: EvaluationMetrics | None
|
|
334
|
+
artifact_uri: str | None
|
|
335
|
+
report_uri: str | None
|
|
336
|
+
sample_results: list[dict]
|
|
337
|
+
error_message: str | None
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
class EvaluationReportResponse(TypedDict):
|
|
341
|
+
"""Response with evaluation report."""
|
|
342
|
+
|
|
343
|
+
eval_id: str
|
|
344
|
+
corpus_id: str
|
|
345
|
+
format: str
|
|
346
|
+
report_uri: str | None
|
|
347
|
+
metrics: EvaluationMetrics | None
|
|
348
|
+
recommendations: list[str]
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
# =============================================================================
|
|
352
|
+
# Document Summarization
|
|
353
|
+
# =============================================================================
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
class SummarizationRequest(TypedDict, total=False):
|
|
357
|
+
"""Request to generate document summaries."""
|
|
358
|
+
|
|
359
|
+
force_regenerate: NotRequired[bool]
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
class SummarizationResponse(TypedDict):
|
|
363
|
+
"""Response after starting summarization."""
|
|
364
|
+
|
|
365
|
+
corpus_id: str
|
|
366
|
+
job_id: str | None
|
|
367
|
+
status: str
|
|
368
|
+
total_documents: int
|
|
369
|
+
documents_with_summaries: int
|
|
370
|
+
documents_to_summarize: int
|
|
371
|
+
created_at: str
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
class SummarizationStatusResponse(TypedDict):
|
|
375
|
+
"""Response showing summarization status for a corpus."""
|
|
376
|
+
|
|
377
|
+
corpus_id: str
|
|
378
|
+
total_documents: int
|
|
379
|
+
documents_with_summaries: int
|
|
380
|
+
coverage_percent: float
|
|
381
|
+
latest_job_status: str | None
|
|
382
|
+
latest_job_completed_at: str | None
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class DocumentSummaryResponse(TypedDict):
|
|
386
|
+
"""Response with a document's summary."""
|
|
387
|
+
|
|
388
|
+
document_id: str
|
|
389
|
+
corpus_id: str
|
|
390
|
+
summary: str
|
|
391
|
+
document_type: str | None
|
|
392
|
+
entities: dict
|
|
393
|
+
key_facts: list[str]
|
|
394
|
+
generation_model: str | None
|
|
395
|
+
created_at: str
|
sdk/types/orgs.py
ADDED
sdk/types/pipelines.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, TypedDict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ValidationIssue(TypedDict, total=False):
|
|
7
|
+
"""A single validation warning or error from dry-run or apply."""
|
|
8
|
+
|
|
9
|
+
severity: str
|
|
10
|
+
code: str
|
|
11
|
+
message: str
|
|
12
|
+
path: str | None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PipelineSpecResponse(TypedDict, total=False):
|
|
16
|
+
"""A single pipeline spec record."""
|
|
17
|
+
|
|
18
|
+
id: str
|
|
19
|
+
org_id: str
|
|
20
|
+
project_id: str
|
|
21
|
+
name: str
|
|
22
|
+
description: str | None
|
|
23
|
+
topology: dict[str, Any]
|
|
24
|
+
status: str
|
|
25
|
+
has_draft: bool
|
|
26
|
+
parent_pipeline_spec_id: str | None
|
|
27
|
+
created_by: str | None
|
|
28
|
+
bound_entity_count: int
|
|
29
|
+
binding_summary: dict[str, Any]
|
|
30
|
+
created_at: str
|
|
31
|
+
updated_at: str
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PipelineSpecListResponse(TypedDict):
|
|
35
|
+
"""Paginated list of pipeline specs."""
|
|
36
|
+
|
|
37
|
+
pipeline_specs: list[PipelineSpecResponse]
|
|
38
|
+
total: int
|
|
39
|
+
limit: int
|
|
40
|
+
offset: int
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class DryRunResult(TypedDict, total=False):
|
|
44
|
+
"""Result of a pipeline spec dry run (validation preview)."""
|
|
45
|
+
|
|
46
|
+
valid: bool
|
|
47
|
+
issues: list[ValidationIssue]
|
|
48
|
+
would_create_agents: int
|
|
49
|
+
would_create_feeds: int
|
|
50
|
+
would_create_corpora: int
|
|
51
|
+
would_bind_existing: int
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ApplyResult(TypedDict, total=False):
|
|
55
|
+
"""Result of applying a pipeline spec."""
|
|
56
|
+
|
|
57
|
+
success: bool
|
|
58
|
+
created_agent_ids: list[str]
|
|
59
|
+
created_feed_ids: list[str]
|
|
60
|
+
created_corpus_ids: list[str]
|
|
61
|
+
created_subscription_ids: list[str]
|
|
62
|
+
bound_entity_ids: list[str]
|
|
63
|
+
issues: list[ValidationIssue]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SkippedEntity(TypedDict, total=False):
|
|
67
|
+
"""Entity skipped during cascade archive."""
|
|
68
|
+
|
|
69
|
+
entity_type: str
|
|
70
|
+
entity_id: str
|
|
71
|
+
entity_name: str
|
|
72
|
+
reason: str
|
|
73
|
+
other_pipeline_ids: list[str]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ArchiveResult(TypedDict, total=False):
|
|
77
|
+
"""Result of archiving a pipeline spec with cascade."""
|
|
78
|
+
|
|
79
|
+
pipeline_spec: PipelineSpecResponse
|
|
80
|
+
archived_agents: list[str]
|
|
81
|
+
archived_feeds: list[str]
|
|
82
|
+
deactivated_subscriptions: list[str]
|
|
83
|
+
skipped_entities: list[SkippedEntity]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class DraftActivateResult(TypedDict, total=False):
|
|
87
|
+
"""Result of activating a pipeline spec draft (incremental apply)."""
|
|
88
|
+
|
|
89
|
+
success: bool
|
|
90
|
+
created_agent_ids: list[str]
|
|
91
|
+
created_feed_ids: list[str]
|
|
92
|
+
created_corpus_ids: list[str]
|
|
93
|
+
created_subscription_ids: list[str]
|
|
94
|
+
removed_binding_ids: list[str]
|
|
95
|
+
updated_entity_ids: list[str]
|
|
96
|
+
issues: list[ValidationIssue]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class FieldDiff(TypedDict, total=False):
|
|
100
|
+
"""Single field-level difference between spec and actual entity state."""
|
|
101
|
+
|
|
102
|
+
field: str
|
|
103
|
+
spec_value: str | None
|
|
104
|
+
actual_value: str | None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class EntityDiff(TypedDict, total=False):
|
|
108
|
+
"""Drift status and field diffs for a single bound entity."""
|
|
109
|
+
|
|
110
|
+
entity_type: str
|
|
111
|
+
entity_id: str
|
|
112
|
+
entity_name: str
|
|
113
|
+
drift_status: str
|
|
114
|
+
field_diffs: list[FieldDiff]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class DriftSummary(TypedDict, total=False):
|
|
118
|
+
"""Summary counts for a drift report."""
|
|
119
|
+
|
|
120
|
+
total_entities: int
|
|
121
|
+
in_sync: int
|
|
122
|
+
drifted: int
|
|
123
|
+
missing: int
|
|
124
|
+
untracked: int
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class DriftReport(TypedDict, total=False):
|
|
128
|
+
"""Full drift report comparing pipeline spec topology vs actual entity state."""
|
|
129
|
+
|
|
130
|
+
pipeline_spec_id: str
|
|
131
|
+
status: str
|
|
132
|
+
entity_diffs: list[EntityDiff]
|
|
133
|
+
summary: DriftSummary
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class RefreshChanges(TypedDict, total=False):
|
|
137
|
+
"""Summary of changes made during a pipeline spec refresh."""
|
|
138
|
+
|
|
139
|
+
updated_entities: list[str]
|
|
140
|
+
removed_entities: list[str]
|
|
141
|
+
unchanged_entities: list[str]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class RefreshResult(TypedDict, total=False):
|
|
145
|
+
"""Result of refreshing a pipeline spec from current entity state."""
|
|
146
|
+
|
|
147
|
+
draft_id: str
|
|
148
|
+
changes: RefreshChanges
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class GraphNode(TypedDict, total=False):
|
|
152
|
+
"""A single node in the pipeline graph representation."""
|
|
153
|
+
|
|
154
|
+
id: str
|
|
155
|
+
type: str
|
|
156
|
+
label: str
|
|
157
|
+
metadata: dict[str, Any]
|
|
158
|
+
status: str | None
|
|
159
|
+
binding_role: str | None
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class GraphEdge(TypedDict, total=False):
|
|
163
|
+
"""A single edge in the pipeline graph representation."""
|
|
164
|
+
|
|
165
|
+
source: str
|
|
166
|
+
target: str
|
|
167
|
+
type: str
|
|
168
|
+
metadata: dict[str, Any]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class GraphResponse(TypedDict, total=False):
|
|
172
|
+
"""Full graph representation of a pipeline spec topology."""
|
|
173
|
+
|
|
174
|
+
pipeline_spec_id: str
|
|
175
|
+
status: str
|
|
176
|
+
nodes: list[GraphNode]
|
|
177
|
+
edges: list[GraphEdge]
|
sdk/types/projects.py
ADDED
sdk/types/search.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional, TypedDict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SearchHybridConfig(TypedDict, total=False):
|
|
7
|
+
enabled: bool
|
|
8
|
+
fusion_mode: str
|
|
9
|
+
rrf_k: int
|
|
10
|
+
dense_weight: float
|
|
11
|
+
sparse_weight: float
|
|
12
|
+
metadata_sparse_enabled: bool
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SearchRerankConfig(TypedDict, total=False):
|
|
16
|
+
enabled: bool
|
|
17
|
+
top_k: int
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SearchReturnConfig(TypedDict, total=False):
|
|
21
|
+
include_text: bool
|
|
22
|
+
include_scores: bool
|
|
23
|
+
include_provenance: bool
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class MetadataFilter(TypedDict, total=False):
|
|
27
|
+
"""A single metadata filter predicate."""
|
|
28
|
+
|
|
29
|
+
key: str
|
|
30
|
+
op: str # ==, !=, >, >=, <, <=, in, not_in, contains, text_match
|
|
31
|
+
value: Any
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MetadataFilters(TypedDict, total=False):
|
|
35
|
+
"""Structured metadata filters with logical condition."""
|
|
36
|
+
|
|
37
|
+
filters: list[MetadataFilter]
|
|
38
|
+
condition: str # "and" or "or"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SearchGenerationConfig(TypedDict, total=False):
|
|
42
|
+
model: str
|
|
43
|
+
thinking_budget: int | None
|
|
44
|
+
temperature: float
|
|
45
|
+
max_tokens: int
|
|
46
|
+
context_top_k: int
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class SearchOptions(TypedDict, total=False):
|
|
50
|
+
query: str
|
|
51
|
+
top_k: int
|
|
52
|
+
filters: dict[str, Any] | MetadataFilters
|
|
53
|
+
hybrid: SearchHybridConfig
|
|
54
|
+
rerank: SearchRerankConfig
|
|
55
|
+
return_config: SearchReturnConfig
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class SearchGenerateOptions(TypedDict, total=False):
|
|
59
|
+
query: str
|
|
60
|
+
top_k: int
|
|
61
|
+
filters: dict[str, Any] | MetadataFilters
|
|
62
|
+
hybrid: SearchHybridConfig
|
|
63
|
+
rerank: SearchRerankConfig
|
|
64
|
+
return_config: SearchReturnConfig
|
|
65
|
+
generation: SearchGenerationConfig
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class SearchBatchOptions(TypedDict, total=False):
|
|
69
|
+
queries: list[str]
|
|
70
|
+
top_k: int
|
|
71
|
+
filters: dict[str, Any] | MetadataFilters
|
|
72
|
+
hybrid: SearchHybridConfig
|
|
73
|
+
rerank: SearchRerankConfig
|
|
74
|
+
return_config: SearchReturnConfig
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class SearchResult(TypedDict, total=False):
|
|
78
|
+
chunk_id: str
|
|
79
|
+
score: float | None
|
|
80
|
+
raw_score: float | None
|
|
81
|
+
text: str | None
|
|
82
|
+
custom_metadata: dict | None
|
|
83
|
+
system_metadata: dict | None
|
|
84
|
+
offset_start: int | None
|
|
85
|
+
offset_end: int | None
|
|
86
|
+
page_start: int | None
|
|
87
|
+
page_end: int | None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class SearchColdStartMeta(TypedDict, total=False):
|
|
91
|
+
likely: bool
|
|
92
|
+
dense_cache_hit: bool | None
|
|
93
|
+
sparse_cache_hit: bool | None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class SearchMeta(TypedDict, total=False):
|
|
97
|
+
cold_start: SearchColdStartMeta | None
|
|
98
|
+
warnings: list[str] | None
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class SearchResponse(TypedDict, total=False):
|
|
102
|
+
results: list[SearchResult]
|
|
103
|
+
meta: SearchMeta
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class SearchBatchResponse(TypedDict, total=False):
|
|
107
|
+
responses: list[SearchResponse]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class SearchGenerateResponse(TypedDict, total=False):
|
|
111
|
+
answer: str
|
|
112
|
+
model: str
|
|
113
|
+
thinking_budget: int | None
|
|
114
|
+
results: list[SearchResult]
|
|
115
|
+
meta: SearchMeta
|
|
116
|
+
used_sources: list[str]
|