codemie-sdk-python 0.1.706__py3-none-any.whl → 0.1.707__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.
- codemie_sdk/builders/workflow/definition.py +21 -0
- codemie_sdk/models/assistant.py +66 -0
- codemie_sdk/models/datasource.py +446 -30
- codemie_sdk/models/workflow.py +3 -0
- codemie_sdk/services/datasource.py +105 -24
- {codemie_sdk_python-0.1.706.dist-info → codemie_sdk_python-0.1.707.dist-info}/METADATA +22 -1
- {codemie_sdk_python-0.1.706.dist-info → codemie_sdk_python-0.1.707.dist-info}/RECORD +8 -8
- {codemie_sdk_python-0.1.706.dist-info → codemie_sdk_python-0.1.707.dist-info}/WHEEL +0 -0
|
@@ -186,6 +186,7 @@ class WorkflowTool(BaseModel):
|
|
|
186
186
|
resolve_dynamic_values_in_response: bool = False
|
|
187
187
|
input_key: str | None = None
|
|
188
188
|
tokens_size_limit: int | None = None
|
|
189
|
+
tool_access: list[WorkflowAssistantTool] | None = None
|
|
189
190
|
|
|
190
191
|
|
|
191
192
|
class CustomWorkflowNode(BaseModel):
|
|
@@ -330,6 +331,12 @@ class WorkflowDefinition(BaseModel):
|
|
|
330
331
|
tools: list[WorkflowTool] = Field(default_factory=list)
|
|
331
332
|
custom_nodes: list[CustomWorkflowNode] = Field(default_factory=list)
|
|
332
333
|
states: list[WorkflowState] = Field(default_factory=list)
|
|
334
|
+
# Engine switches read from the top level of the YAML config; unset means
|
|
335
|
+
# the backend default applies.
|
|
336
|
+
enable_summarization_node: bool | None = None
|
|
337
|
+
messages_limit_before_summarization: int | None = Field(None, gt=0)
|
|
338
|
+
tokens_limit_before_summarization: int | None = Field(None, gt=0)
|
|
339
|
+
max_iteration_key_output_limit: int | None = Field(None, gt=0)
|
|
333
340
|
|
|
334
341
|
def to_yaml_config(
|
|
335
342
|
self, resolve_assistant_name: Callable[[str], str] | None = None
|
|
@@ -351,11 +358,25 @@ class WorkflowDefinition(BaseModel):
|
|
|
351
358
|
node.model_dump(exclude_none=True) for node in self.custom_nodes
|
|
352
359
|
],
|
|
353
360
|
"states": [state.model_dump(exclude_none=True) for state in self.states],
|
|
361
|
+
**self._engine_switches(),
|
|
354
362
|
}
|
|
355
363
|
return yaml.safe_dump(
|
|
356
364
|
payload, sort_keys=False, default_flow_style=False, allow_unicode=True
|
|
357
365
|
)
|
|
358
366
|
|
|
367
|
+
def _engine_switches(self) -> dict:
|
|
368
|
+
names = (
|
|
369
|
+
"enable_summarization_node",
|
|
370
|
+
"messages_limit_before_summarization",
|
|
371
|
+
"tokens_limit_before_summarization",
|
|
372
|
+
"max_iteration_key_output_limit",
|
|
373
|
+
)
|
|
374
|
+
return {
|
|
375
|
+
name: getattr(self, name)
|
|
376
|
+
for name in names
|
|
377
|
+
if getattr(self, name) is not None
|
|
378
|
+
}
|
|
379
|
+
|
|
359
380
|
@staticmethod
|
|
360
381
|
def _resolve_assistant(
|
|
361
382
|
key: str,
|
codemie_sdk/models/assistant.py
CHANGED
|
@@ -23,6 +23,10 @@ class ToolDetails(BaseModel):
|
|
|
23
23
|
settings_config: bool = False
|
|
24
24
|
user_description: str | None = None
|
|
25
25
|
settings: Integration | None = None
|
|
26
|
+
auto_credentials_lookup: bool = Field(
|
|
27
|
+
True,
|
|
28
|
+
description="When no integration is pinned, fall back to the consuming user's own integration",
|
|
29
|
+
)
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
class ToolKitDetails(BaseModel):
|
|
@@ -36,6 +40,10 @@ class ToolKitDetails(BaseModel):
|
|
|
36
40
|
settings_config: bool = False
|
|
37
41
|
is_external: bool = False
|
|
38
42
|
settings: Integration | None = None
|
|
43
|
+
auto_credentials_lookup: bool = Field(
|
|
44
|
+
True,
|
|
45
|
+
description="Toolkit-level counterpart of ToolDetails.auto_credentials_lookup",
|
|
46
|
+
)
|
|
39
47
|
|
|
40
48
|
|
|
41
49
|
class ContextType(str, Enum):
|
|
@@ -114,6 +122,15 @@ class MCPServerConfig(BaseModel):
|
|
|
114
122
|
tools: list[str] | None = Field(
|
|
115
123
|
None, description="List of tool names available in this MCP server"
|
|
116
124
|
)
|
|
125
|
+
audience: str | None = Field(
|
|
126
|
+
None,
|
|
127
|
+
description="OAuth2 audience for OIDC token exchange (RFC 8693)",
|
|
128
|
+
)
|
|
129
|
+
auth_config: dict[str, Any] | None = Field(
|
|
130
|
+
None,
|
|
131
|
+
repr=False,
|
|
132
|
+
description="Authentication configuration for this MCP server, stored as a raw dict",
|
|
133
|
+
)
|
|
117
134
|
|
|
118
135
|
|
|
119
136
|
class MCPServerDetails(BaseModel):
|
|
@@ -155,6 +172,46 @@ class BuiltinSubagent(BaseModel):
|
|
|
155
172
|
display_name: str | None = None
|
|
156
173
|
|
|
157
174
|
|
|
175
|
+
class HedgingToolDetails(BaseModel):
|
|
176
|
+
"""Internal tool used as the hedging fast path."""
|
|
177
|
+
|
|
178
|
+
model_config = ConfigDict(extra="ignore")
|
|
179
|
+
|
|
180
|
+
name: str
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class HedgingProviderToolDetails(BaseModel):
|
|
184
|
+
"""External provider tool used as the hedging fast path."""
|
|
185
|
+
|
|
186
|
+
model_config = ConfigDict(extra="ignore")
|
|
187
|
+
|
|
188
|
+
provider_name: str
|
|
189
|
+
toolkit_name: str
|
|
190
|
+
tool_name: str
|
|
191
|
+
datasource_name: str | None = None
|
|
192
|
+
result_condition: str | None = None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class HedgingConfig(BaseModel):
|
|
196
|
+
"""Hedging (fast path) configuration: exactly one of tool or provider_tool."""
|
|
197
|
+
|
|
198
|
+
model_config = ConfigDict(extra="ignore")
|
|
199
|
+
|
|
200
|
+
tool: HedgingToolDetails | None = None
|
|
201
|
+
provider_tool: HedgingProviderToolDetails | None = None
|
|
202
|
+
timeout_ms: int = Field(200, gt=0)
|
|
203
|
+
input_mapping: dict[str, str] = Field(default_factory=dict)
|
|
204
|
+
output_field: str | None = None
|
|
205
|
+
|
|
206
|
+
@model_validator(mode="after")
|
|
207
|
+
def validate_tool_or_provider(self) -> "HedgingConfig":
|
|
208
|
+
if (self.tool is None) == (self.provider_tool is None):
|
|
209
|
+
raise ValueError(
|
|
210
|
+
"Exactly one of 'tool' or 'provider_tool' must be specified"
|
|
211
|
+
)
|
|
212
|
+
return self
|
|
213
|
+
|
|
214
|
+
|
|
158
215
|
class AssistantBase(BaseModel):
|
|
159
216
|
"""Base model for assistant with common fields."""
|
|
160
217
|
|
|
@@ -272,6 +329,10 @@ class Assistant(AssistantBase):
|
|
|
272
329
|
description="Number of times this assistant has been cloned in the Marketplace",
|
|
273
330
|
)
|
|
274
331
|
tool_permissions: ToolPermissionsConfig | None = None
|
|
332
|
+
hedging_config: HedgingConfig | None = None
|
|
333
|
+
interactive_enabled: bool = False
|
|
334
|
+
enable_image_generation: bool | None = False
|
|
335
|
+
file_attachment_enabled: bool | None = None
|
|
275
336
|
|
|
276
337
|
|
|
277
338
|
class AssistantRequestBase(AssistantBase):
|
|
@@ -308,6 +369,11 @@ class AssistantRequestBase(AssistantBase):
|
|
|
308
369
|
prompt_variables: list[PromptVariable] = Field(default_factory=list)
|
|
309
370
|
skip_integration_validation: bool | None = Field(default=False)
|
|
310
371
|
tool_permissions: ToolPermissionsConfig | None = None
|
|
372
|
+
hedging_config: HedgingConfig | None = None
|
|
373
|
+
# None (not sent) on requests so an update never resets the stored flag.
|
|
374
|
+
interactive_enabled: bool | None = None
|
|
375
|
+
enable_image_generation: bool | None = None
|
|
376
|
+
file_attachment_enabled: bool | None = None
|
|
311
377
|
|
|
312
378
|
|
|
313
379
|
class AssistantCreateRequest(AssistantRequestBase):
|
codemie_sdk/models/datasource.py
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import re
|
|
2
3
|
import warnings
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from enum import Enum
|
|
5
|
-
from typing import Tuple
|
|
6
|
-
|
|
7
|
-
from pydantic import
|
|
6
|
+
from typing import Any, Callable, Literal, Tuple
|
|
7
|
+
|
|
8
|
+
from pydantic import (
|
|
9
|
+
AliasChoices,
|
|
10
|
+
BaseModel,
|
|
11
|
+
ConfigDict,
|
|
12
|
+
Field,
|
|
13
|
+
ValidationError,
|
|
14
|
+
field_validator,
|
|
15
|
+
model_validator,
|
|
16
|
+
)
|
|
8
17
|
|
|
9
18
|
from .common import TokensUsage, User
|
|
10
19
|
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
11
22
|
|
|
12
23
|
class CodeDataSourceType(str, Enum):
|
|
13
24
|
CODE = "code"
|
|
@@ -33,6 +44,10 @@ class DataSourceType(str, Enum):
|
|
|
33
44
|
AZURE_DEVOPS_WORK_ITEM = "knowledge_base_azure_devops_work_item"
|
|
34
45
|
SHAREPOINT = "knowledge_base_sharepoint"
|
|
35
46
|
XWIKI = "knowledge_base_xwiki"
|
|
47
|
+
# Request routing only: the backend stores SVN datasources with the index_type
|
|
48
|
+
# the caller picked (code / summary / chunk-summary) and vcs_type="svn", so
|
|
49
|
+
# filtering list() by SVN returns nothing.
|
|
50
|
+
SVN = "svn"
|
|
36
51
|
|
|
37
52
|
|
|
38
53
|
class DataSourceStatus(str, Enum):
|
|
@@ -135,9 +150,113 @@ class XWiki(BaseModel):
|
|
|
135
150
|
model_config = ConfigDict(extra="ignore")
|
|
136
151
|
|
|
137
152
|
|
|
153
|
+
class Svn(BaseModel):
|
|
154
|
+
"""Model for SVN repository datasource fields.
|
|
155
|
+
|
|
156
|
+
Note: the backend PUT resets omitted prompt, files_filter, project_space_visible
|
|
157
|
+
and docs_generation to defaults, so send them on every update. The update
|
|
158
|
+
request uses the camelCase names the backend update endpoint reads.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
link: str = Field(..., min_length=1, max_length=1000)
|
|
162
|
+
branch: str = Field("trunk", min_length=1, max_length=1000)
|
|
163
|
+
files_filter: str | None = None
|
|
164
|
+
embeddings_model: str | None = None
|
|
165
|
+
prompt: str | None = None
|
|
166
|
+
docs_generation: bool | None = None
|
|
167
|
+
|
|
168
|
+
model_config = ConfigDict(extra="ignore")
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class SharePoint(BaseModel):
|
|
172
|
+
"""Model for SharePoint-specific request fields."""
|
|
173
|
+
|
|
174
|
+
site_url: str = Field(..., pattern=r"^https://\S+$", max_length=1000)
|
|
175
|
+
include_pages: bool | None = None
|
|
176
|
+
include_documents: bool | None = None
|
|
177
|
+
include_lists: bool | None = None
|
|
178
|
+
max_file_size_mb: int | None = Field(None, ge=1, le=500)
|
|
179
|
+
files_filter: str | None = None
|
|
180
|
+
auth_type: Literal["integration", "oauth_codemie", "oauth_custom"] | None = None
|
|
181
|
+
oauth_client_id: str | None = None
|
|
182
|
+
oauth_tenant_id: str | None = None
|
|
183
|
+
access_token: str | None = Field(None, repr=False)
|
|
184
|
+
embedding_model: str | None = None
|
|
185
|
+
|
|
186
|
+
model_config = ConfigDict(extra="ignore")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class Xray(BaseModel):
|
|
190
|
+
"""Model for Xray-specific fields"""
|
|
191
|
+
|
|
192
|
+
jql: str = Field(..., min_length=1)
|
|
193
|
+
embedding_model: str | None = None
|
|
194
|
+
|
|
195
|
+
model_config = ConfigDict(extra="ignore")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class SvnInfo(BaseModel):
|
|
199
|
+
"""Typed read of the SVN settings stored on a datasource (vcs_type=svn)."""
|
|
200
|
+
|
|
201
|
+
link: str | None = None
|
|
202
|
+
branch: str | None = None
|
|
203
|
+
files_filter: str | None = None
|
|
204
|
+
embeddings_model: str | None = None
|
|
205
|
+
prompt: str | None = None
|
|
206
|
+
docs_generation: bool | None = None
|
|
207
|
+
|
|
208
|
+
model_config = ConfigDict(extra="ignore")
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class SharePointInfo(BaseModel):
|
|
212
|
+
"""Typed read of the nested SharePoint config (credentials are not exposed)."""
|
|
213
|
+
|
|
214
|
+
site_url: str | None = None
|
|
215
|
+
include_pages: bool | None = None
|
|
216
|
+
include_documents: bool | None = None
|
|
217
|
+
include_lists: bool | None = None
|
|
218
|
+
max_file_size_mb: int | None = None
|
|
219
|
+
files_filter: str | None = None
|
|
220
|
+
auth_type: str | None = None
|
|
221
|
+
oauth_client_id: str | None = None
|
|
222
|
+
oauth_tenant_id: str | None = None
|
|
223
|
+
|
|
224
|
+
model_config = ConfigDict(extra="ignore")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class XrayInfo(BaseModel):
|
|
228
|
+
"""Typed read of the nested Xray config."""
|
|
229
|
+
|
|
230
|
+
jql: str | None = None
|
|
231
|
+
|
|
232
|
+
model_config = ConfigDict(extra="ignore")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class ProviderFields(BaseModel):
|
|
236
|
+
"""Typed read of provider datasource settings.
|
|
237
|
+
|
|
238
|
+
Sensitive params are encrypted at rest, so a read can return ciphertext rather
|
|
239
|
+
than the secret. On update, send ``**********`` for a secret to keep the stored
|
|
240
|
+
value.
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
provider_id: str | None = None
|
|
244
|
+
toolkit_id: str | None = None
|
|
245
|
+
base_params: dict[str, Any] = Field(default_factory=dict)
|
|
246
|
+
create_params: dict[str, Any] = Field(default_factory=dict)
|
|
247
|
+
|
|
248
|
+
model_config = ConfigDict(extra="ignore")
|
|
249
|
+
|
|
250
|
+
@field_validator("base_params", "create_params", mode="before")
|
|
251
|
+
def null_params_as_empty(cls, value):
|
|
252
|
+
return {} if value is None else value
|
|
253
|
+
|
|
254
|
+
|
|
138
255
|
class Code(BaseModel):
|
|
139
256
|
"""Model for code repository datasource creation"""
|
|
140
257
|
|
|
258
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
259
|
+
|
|
141
260
|
link: str | None = Field(..., min_length=1, max_length=1000)
|
|
142
261
|
branch: str | None = Field(..., min_length=1, max_length=1000)
|
|
143
262
|
index_type: CodeDataSourceType | None = Field(None, alias="indexType")
|
|
@@ -157,6 +276,32 @@ class GitFaq(BaseModel):
|
|
|
157
276
|
embedding_model: str | None = Field(None)
|
|
158
277
|
|
|
159
278
|
|
|
279
|
+
class CodeInfo(BaseModel):
|
|
280
|
+
"""Typed read of a code datasource's settings; every field is optional."""
|
|
281
|
+
|
|
282
|
+
link: str | None = None
|
|
283
|
+
branch: str | None = None
|
|
284
|
+
index_type: CodeDataSourceType | None = None
|
|
285
|
+
files_filter: str | None = None
|
|
286
|
+
embeddings_model: str | None = None
|
|
287
|
+
summarization_model: str | None = None
|
|
288
|
+
prompt: str | None = None
|
|
289
|
+
docs_generation: bool | None = None
|
|
290
|
+
|
|
291
|
+
model_config = ConfigDict(extra="ignore")
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class GitFaqInfo(BaseModel):
|
|
295
|
+
"""Typed read of a Git FAQ datasource's settings; every field is optional."""
|
|
296
|
+
|
|
297
|
+
link: str | None = None
|
|
298
|
+
branch: str | None = None
|
|
299
|
+
files_filter: str | None = None
|
|
300
|
+
embedding_model: str | None = None
|
|
301
|
+
|
|
302
|
+
model_config = ConfigDict(extra="ignore")
|
|
303
|
+
|
|
304
|
+
|
|
160
305
|
class BaseDataSourceRequest(BaseModel):
|
|
161
306
|
"""Base model for all datasource creation requests"""
|
|
162
307
|
|
|
@@ -280,6 +425,61 @@ class XWikiDataSourceRequest(BaseDataSourceRequest, XWiki):
|
|
|
280
425
|
return ["space"]
|
|
281
426
|
|
|
282
427
|
|
|
428
|
+
class SvnDataSourceRequest(BaseDataSourceRequest, Svn):
|
|
429
|
+
"""Model for SVN datasource creation requests"""
|
|
430
|
+
|
|
431
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
432
|
+
|
|
433
|
+
index_type: CodeDataSourceType = Field(..., alias="indexType")
|
|
434
|
+
# Used by the summary and chunk-summary index types; the backend falls back
|
|
435
|
+
# to its default model when omitted.
|
|
436
|
+
summarization_model: str | None = Field(None, alias="summarizationModel")
|
|
437
|
+
|
|
438
|
+
def __init__(self, **data):
|
|
439
|
+
super().__init__(type=DataSourceType.SVN, **data)
|
|
440
|
+
|
|
441
|
+
@classmethod
|
|
442
|
+
def required_fields(cls) -> list[str]:
|
|
443
|
+
return ["link"]
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class SharePointDataSourceRequest(BaseDataSourceRequest, SharePoint):
|
|
447
|
+
"""Model for SharePoint datasource creation requests"""
|
|
448
|
+
|
|
449
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
450
|
+
|
|
451
|
+
@model_validator(mode="after")
|
|
452
|
+
def validate_oauth_access_token(self):
|
|
453
|
+
if (
|
|
454
|
+
self.auth_type in ("oauth_codemie", "oauth_custom")
|
|
455
|
+
and not self.access_token
|
|
456
|
+
):
|
|
457
|
+
raise ValueError(
|
|
458
|
+
"access_token is required when auth_type is 'oauth_codemie' or 'oauth_custom'"
|
|
459
|
+
)
|
|
460
|
+
return self
|
|
461
|
+
|
|
462
|
+
def __init__(self, **data):
|
|
463
|
+
super().__init__(type=DataSourceType.SHAREPOINT, **data)
|
|
464
|
+
|
|
465
|
+
@classmethod
|
|
466
|
+
def required_fields(cls) -> list[str]:
|
|
467
|
+
return ["site_url"]
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
class XrayDataSourceRequest(BaseDataSourceRequest, Xray):
|
|
471
|
+
"""Model for Xray datasource creation requests"""
|
|
472
|
+
|
|
473
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
474
|
+
|
|
475
|
+
def __init__(self, **data):
|
|
476
|
+
super().__init__(type=DataSourceType.XRAY, **data)
|
|
477
|
+
|
|
478
|
+
@classmethod
|
|
479
|
+
def required_fields(cls) -> list[str]:
|
|
480
|
+
return ["jql"]
|
|
481
|
+
|
|
482
|
+
|
|
283
483
|
class BaseUpdateDataSourceRequest(BaseDataSourceRequest):
|
|
284
484
|
"""Mixin update-specific reindex fields"""
|
|
285
485
|
|
|
@@ -387,6 +587,88 @@ class UpdateXWikiDataSourceRequest(BaseUpdateDataSourceRequest, XWiki):
|
|
|
387
587
|
super().__init__(type=DataSourceType.XWIKI, **data)
|
|
388
588
|
|
|
389
589
|
|
|
590
|
+
class UpdateSvnDataSourceRequest(BaseUpdateDataSourceRequest, Svn):
|
|
591
|
+
"""Model for SVN datasource updates (camelCase keys, as the backend reads them)"""
|
|
592
|
+
|
|
593
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
594
|
+
|
|
595
|
+
# The backend writes these four on every update, sent or not (a missing
|
|
596
|
+
# visibility flag becomes True, a missing prompt / filter / docs flag is
|
|
597
|
+
# wiped), so the caller states each one. ``None`` is allowed for the
|
|
598
|
+
# nullable three and means "clear it"; it is not sent.
|
|
599
|
+
shared_with_project: bool = Field(
|
|
600
|
+
...,
|
|
601
|
+
validation_alias=AliasChoices(
|
|
602
|
+
"projectSpaceVisible", "project_space_visible", "shared_with_project"
|
|
603
|
+
),
|
|
604
|
+
serialization_alias="projectSpaceVisible",
|
|
605
|
+
)
|
|
606
|
+
prompt: str | None = Field(...)
|
|
607
|
+
files_filter: str | None = Field(..., alias="filesFilter")
|
|
608
|
+
docs_generation: bool | None = Field(..., alias="docsGeneration")
|
|
609
|
+
# Optional on update: the backend overwrites the stored link / branch when sent.
|
|
610
|
+
link: str | None = Field(None, min_length=1, max_length=1000)
|
|
611
|
+
branch: str | None = Field(None, min_length=1, max_length=1000)
|
|
612
|
+
embeddings_model: str | None = Field(None, alias="embeddingsModel")
|
|
613
|
+
|
|
614
|
+
def __init__(self, **data):
|
|
615
|
+
super().__init__(type=DataSourceType.SVN, **data)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
class UpdateSharePointDataSourceRequest(BaseUpdateDataSourceRequest, SharePoint):
|
|
619
|
+
"""Model for SharePoint datasource updates (site_url is optional: omit to keep it).
|
|
620
|
+
|
|
621
|
+
The OAuth ``access_token`` check for ``full_reindex`` only sees an explicit
|
|
622
|
+
``auth_type``. When ``auth_type`` is omitted to keep the stored value, the SDK
|
|
623
|
+
cannot know it, so pass ``access_token`` on every ``full_reindex`` of an OAuth
|
|
624
|
+
datasource: the backend saves the update first and refuses the reindex
|
|
625
|
+
afterwards (422), leaving a partial update.
|
|
626
|
+
"""
|
|
627
|
+
|
|
628
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
629
|
+
|
|
630
|
+
site_url: str | None = Field(None, pattern=r"^https://\S+$", max_length=1000)
|
|
631
|
+
# None keeps the stored value (the backend update treats a missing flag so).
|
|
632
|
+
shared_with_project: bool | None = Field(None, alias="project_space_visible")
|
|
633
|
+
|
|
634
|
+
@model_validator(mode="after")
|
|
635
|
+
def validate_oauth_reindex_token(self):
|
|
636
|
+
# The backend saves the update first and only then refuses a reindex of an
|
|
637
|
+
# OAuth datasource without a token (422), leaving a partial apply. Only an
|
|
638
|
+
# explicit auth_type can be checked here; a stored OAuth type with
|
|
639
|
+
# auth_type omitted still needs the token on every full_reindex.
|
|
640
|
+
if (
|
|
641
|
+
self.full_reindex
|
|
642
|
+
and self.auth_type in ("oauth_codemie", "oauth_custom")
|
|
643
|
+
and not self.access_token
|
|
644
|
+
):
|
|
645
|
+
raise ValueError(
|
|
646
|
+
"access_token is required for full_reindex when auth_type is "
|
|
647
|
+
"'oauth_codemie' or 'oauth_custom'"
|
|
648
|
+
)
|
|
649
|
+
return self
|
|
650
|
+
|
|
651
|
+
def __init__(self, **data):
|
|
652
|
+
super().__init__(type=DataSourceType.SHAREPOINT, **data)
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
class UpdateXrayDataSourceRequest(BaseUpdateDataSourceRequest):
|
|
656
|
+
"""Model for Xray datasource updates.
|
|
657
|
+
|
|
658
|
+
Does not extend ``Xray``: the backend update ignores ``embedding_model`` (it is
|
|
659
|
+
create-only), so it is rejected here instead of being sent and dropped.
|
|
660
|
+
"""
|
|
661
|
+
|
|
662
|
+
model_config = ConfigDict(populate_by_name=True, extra="forbid")
|
|
663
|
+
|
|
664
|
+
jql: str = Field(..., min_length=1)
|
|
665
|
+
# None keeps the stored value (the backend update treats a missing flag so).
|
|
666
|
+
shared_with_project: bool | None = Field(None, alias="project_space_visible")
|
|
667
|
+
|
|
668
|
+
def __init__(self, **data):
|
|
669
|
+
super().__init__(type=DataSourceType.XRAY, **data)
|
|
670
|
+
|
|
671
|
+
|
|
390
672
|
class CodeAnalysisDataSourceRequest(BaseModel):
|
|
391
673
|
"""Model for provider-based datasource creation requests.
|
|
392
674
|
|
|
@@ -400,7 +682,15 @@ class CodeAnalysisDataSourceRequest(BaseModel):
|
|
|
400
682
|
model_config = ConfigDict(extra="ignore", populate_by_name=True)
|
|
401
683
|
|
|
402
684
|
name: str = Field(..., description="Datasource name")
|
|
403
|
-
|
|
685
|
+
# The backend needs a string to create the datasource, so an omitted or
|
|
686
|
+
# None description becomes "".
|
|
687
|
+
description: str | None = Field("", description="Datasource description")
|
|
688
|
+
|
|
689
|
+
@field_validator("description", mode="before")
|
|
690
|
+
@classmethod
|
|
691
|
+
def _none_description_is_empty(cls, value):
|
|
692
|
+
return "" if value is None else value
|
|
693
|
+
|
|
404
694
|
project_name: str = Field(..., description="Project name")
|
|
405
695
|
project_space_visible: bool = Field(
|
|
406
696
|
False, description="Make the datasource visible to the whole project"
|
|
@@ -430,7 +720,15 @@ class CodeExplorationDataSourceRequest(BaseModel):
|
|
|
430
720
|
model_config = ConfigDict(extra="ignore", populate_by_name=True)
|
|
431
721
|
|
|
432
722
|
name: str = Field(..., description="Datasource name")
|
|
433
|
-
|
|
723
|
+
# The backend needs a string to create the datasource, so an omitted or
|
|
724
|
+
# None description becomes "".
|
|
725
|
+
description: str | None = Field("", description="Datasource description")
|
|
726
|
+
|
|
727
|
+
@field_validator("description", mode="before")
|
|
728
|
+
@classmethod
|
|
729
|
+
def _none_description_is_empty(cls, value):
|
|
730
|
+
return "" if value is None else value
|
|
731
|
+
|
|
434
732
|
project_name: str = Field(..., description="Project name")
|
|
435
733
|
project_space_visible: bool = Field(
|
|
436
734
|
False, description="Make the datasource visible to the whole project"
|
|
@@ -444,6 +742,46 @@ class CodeExplorationDataSourceRequest(BaseModel):
|
|
|
444
742
|
)
|
|
445
743
|
|
|
446
744
|
|
|
745
|
+
class _ProviderRequestBase(BaseModel):
|
|
746
|
+
"""Shared fields and body of the provider create and update requests."""
|
|
747
|
+
|
|
748
|
+
model_config = ConfigDict(extra="ignore", populate_by_name=True)
|
|
749
|
+
|
|
750
|
+
# The backend writes name, project_name, description and
|
|
751
|
+
# project_space_visible from the body on every update without a None check,
|
|
752
|
+
# so all four are required (a missing one is stored as NULL and the save fails).
|
|
753
|
+
name: str = Field(..., min_length=1)
|
|
754
|
+
project_name: str = Field(..., min_length=1)
|
|
755
|
+
description: str
|
|
756
|
+
project_space_visible: bool
|
|
757
|
+
settings: dict[str, Any] = Field(default_factory=dict)
|
|
758
|
+
|
|
759
|
+
def to_body(self) -> dict[str, Any]:
|
|
760
|
+
"""Body with name, project_name, description and project_space_visible
|
|
761
|
+
merged with settings."""
|
|
762
|
+
return {
|
|
763
|
+
**self.settings,
|
|
764
|
+
"name": self.name,
|
|
765
|
+
"project_name": self.project_name,
|
|
766
|
+
"description": self.description,
|
|
767
|
+
"project_space_visible": self.project_space_visible,
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
class UpdateProviderDataSourceRequest(_ProviderRequestBase):
|
|
772
|
+
"""Typed update request for provider datasources."""
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
class ProviderDataSourceRequest(_ProviderRequestBase):
|
|
776
|
+
"""Typed create request for provider datasources.
|
|
777
|
+
|
|
778
|
+
provider_name and toolkit_id are sent as query params, not in the body.
|
|
779
|
+
"""
|
|
780
|
+
|
|
781
|
+
provider_name: str
|
|
782
|
+
toolkit_id: str
|
|
783
|
+
|
|
784
|
+
|
|
447
785
|
class DataSource(BaseModel):
|
|
448
786
|
model_config = ConfigDict(
|
|
449
787
|
extra="ignore",
|
|
@@ -464,6 +802,8 @@ class DataSource(BaseModel):
|
|
|
464
802
|
created_date: datetime = Field(None, alias="date")
|
|
465
803
|
created_by: User
|
|
466
804
|
shared_with_project: bool = Field(None, alias="project_space_visible")
|
|
805
|
+
cron_expression: str | None = None
|
|
806
|
+
timezone: str | None = None
|
|
467
807
|
update_date: datetime
|
|
468
808
|
error_message: str | None = Field(None, alias="text")
|
|
469
809
|
user_abilities: list[str]
|
|
@@ -471,8 +811,8 @@ class DataSource(BaseModel):
|
|
|
471
811
|
processed_documents: list[str] | None = Field(None, alias="processed_files")
|
|
472
812
|
tokens_usage: TokensUsage | None = Field(None)
|
|
473
813
|
# Code specific fields
|
|
474
|
-
code:
|
|
475
|
-
git_faq:
|
|
814
|
+
code: CodeInfo | None = None
|
|
815
|
+
git_faq: GitFaqInfo | None = None
|
|
476
816
|
# Jira specific fields
|
|
477
817
|
jira: Jira | None = None
|
|
478
818
|
# Confluence specific fields
|
|
@@ -485,6 +825,27 @@ class DataSource(BaseModel):
|
|
|
485
825
|
azure_devops_work_item: AzureDevOpsWorkItem | None = None
|
|
486
826
|
# xWiki specific fields
|
|
487
827
|
xwiki: XWiki | None = None
|
|
828
|
+
# SVN, SharePoint, Xray and provider specific fields
|
|
829
|
+
svn: SvnInfo | None = None
|
|
830
|
+
sharepoint: SharePointInfo | None = None
|
|
831
|
+
xray: XrayInfo | None = None
|
|
832
|
+
provider: ProviderFields | None = None
|
|
833
|
+
|
|
834
|
+
@field_validator(
|
|
835
|
+
"code", "git_faq", "svn", "sharepoint", "xray", "provider", mode="wrap"
|
|
836
|
+
)
|
|
837
|
+
def tolerate_unreadable_sub_object(cls, value, handler, info):
|
|
838
|
+
# One stored record with an unexpected shape must not break the whole read.
|
|
839
|
+
try:
|
|
840
|
+
return handler(value)
|
|
841
|
+
except ValidationError as error:
|
|
842
|
+
logger.warning(
|
|
843
|
+
"Ignoring unreadable %s settings of datasource %s: %s",
|
|
844
|
+
info.field_name,
|
|
845
|
+
info.data.get("id"),
|
|
846
|
+
error.errors(include_url=False, include_input=False),
|
|
847
|
+
)
|
|
848
|
+
return None
|
|
488
849
|
|
|
489
850
|
@model_validator(mode="before")
|
|
490
851
|
def before_init(cls, values):
|
|
@@ -497,32 +858,87 @@ class DataSource(BaseModel):
|
|
|
497
858
|
else:
|
|
498
859
|
values["status"] = DataSourceStatus.IN_PROGRESS
|
|
499
860
|
|
|
500
|
-
|
|
861
|
+
builder = _INDEX_TYPE_BUILDERS.get(values.get("index_type"))
|
|
862
|
+
if builder:
|
|
863
|
+
builder(values)
|
|
864
|
+
if values.get("provider_fields"):
|
|
865
|
+
values["provider"] = values["provider_fields"]
|
|
866
|
+
return values
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
def _picked(values: dict, model: type[BaseModel]) -> dict:
|
|
870
|
+
return {name: values[name] for name in model.model_fields if name in values}
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
def _build_processing_info(values: dict) -> None:
|
|
874
|
+
complete_state = values.get("complete_state", 0)
|
|
875
|
+
if complete_state is not None:
|
|
876
|
+
values["processing_info"] = {"documents_count_key": complete_state}
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
def _sub_object_builder(
|
|
880
|
+
key: str,
|
|
881
|
+
source: Callable[[dict], dict],
|
|
882
|
+
) -> Callable[[dict], None]:
|
|
883
|
+
def build(values: dict) -> None:
|
|
884
|
+
values[key] = source(values)
|
|
885
|
+
|
|
886
|
+
return build
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
def _present(values: dict, names: tuple[str, ...]) -> dict:
|
|
890
|
+
return {name: values[name] for name in names if values.get(name) is not None}
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
def _git_faq_source(values: dict) -> dict:
|
|
894
|
+
data = _present(values, ("link", "branch", "files_filter"))
|
|
895
|
+
if values.get("embeddings_model") is not None:
|
|
896
|
+
data["embedding_model"] = values["embeddings_model"]
|
|
897
|
+
return data
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
_CODE_FIELDS = (
|
|
901
|
+
"link",
|
|
902
|
+
"branch",
|
|
903
|
+
"index_type",
|
|
904
|
+
"files_filter",
|
|
905
|
+
"embeddings_model",
|
|
906
|
+
"summarization_model",
|
|
907
|
+
"prompt",
|
|
908
|
+
"docs_generation",
|
|
909
|
+
)
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
def _code_source(values: dict) -> dict:
|
|
913
|
+
return _present(values, _CODE_FIELDS)
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
_build_git_faq = _sub_object_builder("git_faq", _git_faq_source)
|
|
917
|
+
_build_code_info = _sub_object_builder("code", _code_source)
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
def _build_code(values: dict) -> None:
|
|
921
|
+
_build_code_info(values)
|
|
922
|
+
# SVN datasources are stored with a code index_type and vcs_type="svn".
|
|
923
|
+
if values.get("vcs_type") == "svn":
|
|
924
|
+
values["svn"] = _picked(values, SvnInfo)
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
# index_type -> builder that derives typed sub-objects from the flat payload.
|
|
928
|
+
_INDEX_TYPE_BUILDERS: dict[str, Callable[[dict], None]] = {
|
|
929
|
+
**{
|
|
930
|
+
index_type: _build_processing_info
|
|
931
|
+
for index_type in (
|
|
501
932
|
DataSourceType.CONFLUENCE,
|
|
502
933
|
DataSourceType.JIRA,
|
|
503
934
|
DataSourceType.GOOGLE,
|
|
504
935
|
DataSourceType.AZURE_DEVOPS_WIKI,
|
|
505
936
|
DataSourceType.AZURE_DEVOPS_WORK_ITEM,
|
|
506
937
|
DataSourceType.XWIKI,
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
"branch": values.get("branch"),
|
|
515
|
-
"files_filter": values.get("files_filter"),
|
|
516
|
-
"setting_id": values.get("setting_id"),
|
|
517
|
-
}
|
|
518
|
-
elif values.get("index_type") == DataSourceType.CODE:
|
|
519
|
-
values["code"] = {
|
|
520
|
-
"link": values.get("link"),
|
|
521
|
-
"branch": values.get("branch"),
|
|
522
|
-
"files_filter": values.get("files_filter"),
|
|
523
|
-
"summarization_prompt": values.get("prompt"),
|
|
524
|
-
"summarization_model": values.get("summarization_model"),
|
|
525
|
-
"summarization_docs_generation": values.get("docs_generation"),
|
|
526
|
-
"embeddings_model": values.get("embeddings_model"),
|
|
527
|
-
}
|
|
528
|
-
return values
|
|
938
|
+
)
|
|
939
|
+
},
|
|
940
|
+
DataSourceType.GIT_FAQ: _build_git_faq,
|
|
941
|
+
DataSourceType.CODE: _build_code,
|
|
942
|
+
DataSourceType.SUMMARY: _build_code,
|
|
943
|
+
DataSourceType.CHUNK_SUMMARY: _build_code,
|
|
944
|
+
}
|
codemie_sdk/models/workflow.py
CHANGED
|
@@ -23,6 +23,7 @@ class WorkflowCreateRequest(BaseModel):
|
|
|
23
23
|
project: str = Field(..., min_length=1)
|
|
24
24
|
name: str = Field(..., min_length=1)
|
|
25
25
|
description: str | None = None
|
|
26
|
+
start_hint: str | None = None
|
|
26
27
|
yaml_config: str = Field(..., min_length=1)
|
|
27
28
|
mode: WorkflowMode = WorkflowMode.SEQUENTIAL
|
|
28
29
|
shared: bool = False
|
|
@@ -37,6 +38,7 @@ class WorkflowUpdateRequest(BaseModel):
|
|
|
37
38
|
project: str = Field(..., min_length=1)
|
|
38
39
|
name: str = Field(..., min_length=1)
|
|
39
40
|
description: str = Field(..., min_length=1)
|
|
41
|
+
start_hint: str | None = None
|
|
40
42
|
yaml_config: str = Field(..., min_length=1)
|
|
41
43
|
mode: WorkflowMode | None = None
|
|
42
44
|
shared: bool | None = None
|
|
@@ -56,6 +58,7 @@ class Workflow(BaseModel):
|
|
|
56
58
|
project: str
|
|
57
59
|
name: str
|
|
58
60
|
description: str | None = None
|
|
61
|
+
start_hint: str | None = None
|
|
59
62
|
yaml_config: str | None = None
|
|
60
63
|
mode: WorkflowMode = WorkflowMode.SEQUENTIAL
|
|
61
64
|
shared: bool = False
|
|
@@ -4,7 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import mimetypes
|
|
7
|
-
from
|
|
7
|
+
from urllib.parse import quote, urlencode
|
|
8
|
+
from typing import Callable, Literal, Tuple, Any
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
10
11
|
from ..models.common import PaginationParams
|
|
@@ -13,19 +14,74 @@ from ..models.datasource import (
|
|
|
13
14
|
DataSourceType,
|
|
14
15
|
DataSourceStatus,
|
|
15
16
|
BaseDataSourceRequest,
|
|
16
|
-
CodeDataSourceRequest,
|
|
17
|
-
UpdateCodeDataSourceRequest,
|
|
18
17
|
BaseUpdateDataSourceRequest,
|
|
19
18
|
FileDataSourceRequest,
|
|
20
19
|
UpdateFileDataSourceRequest,
|
|
21
20
|
CodeAnalysisDataSourceRequest,
|
|
22
21
|
CodeExplorationDataSourceRequest,
|
|
23
22
|
ElasticsearchStatsResponse,
|
|
23
|
+
ProviderDataSourceRequest,
|
|
24
|
+
UpdateProviderDataSourceRequest,
|
|
24
25
|
)
|
|
25
26
|
from ..models.assistant import AssistantListResponse
|
|
26
27
|
from ..utils import ApiRequestHandler, TokenSource
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
def _application_route(suffix: str = "") -> Callable[[BaseDataSourceRequest], str]:
|
|
31
|
+
return lambda request: (
|
|
32
|
+
f"/v1/application/{quote(request.project_name, safe='')}/index{suffix}"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _knowledge_base_route(segment: str) -> Callable[[BaseDataSourceRequest], str]:
|
|
37
|
+
return lambda _request: f"/v1/index/knowledge_base/{segment}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Explicit route table: base endpoint per datasource type (used by create and update).
|
|
41
|
+
_ROUTES: dict[DataSourceType, Callable[[BaseDataSourceRequest], str]] = {
|
|
42
|
+
DataSourceType.CODE: _application_route(),
|
|
43
|
+
DataSourceType.SVN: _application_route("/svn"),
|
|
44
|
+
DataSourceType.CONFLUENCE: _knowledge_base_route("confluence"),
|
|
45
|
+
DataSourceType.JIRA: _knowledge_base_route("jira"),
|
|
46
|
+
DataSourceType.FILE: _knowledge_base_route("file"),
|
|
47
|
+
DataSourceType.XRAY: _knowledge_base_route("xray"),
|
|
48
|
+
DataSourceType.GOOGLE: _knowledge_base_route("google"),
|
|
49
|
+
DataSourceType.GIT_FAQ: _knowledge_base_route("git_faq"),
|
|
50
|
+
DataSourceType.AZURE_DEVOPS_WIKI: _knowledge_base_route("azure_devops_wiki"),
|
|
51
|
+
DataSourceType.AZURE_DEVOPS_WORK_ITEM: _knowledge_base_route(
|
|
52
|
+
"azure_devops_work_item"
|
|
53
|
+
),
|
|
54
|
+
DataSourceType.SHAREPOINT: _knowledge_base_route("sharepoint"),
|
|
55
|
+
DataSourceType.XWIKI: _knowledge_base_route("xwiki"),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Types whose update endpoint addresses the datasource by name in the path.
|
|
59
|
+
_NAME_IN_UPDATE_PATH = frozenset({DataSourceType.CODE, DataSourceType.SVN})
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _create_endpoint(request: BaseDataSourceRequest) -> str:
|
|
63
|
+
route = _ROUTES.get(request.type)
|
|
64
|
+
if route is None:
|
|
65
|
+
raise ValueError(f"Unsupported datasource type: {request.type}")
|
|
66
|
+
return route(request)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _update_endpoint(request: BaseDataSourceRequest) -> str:
|
|
70
|
+
endpoint = _create_endpoint(request)
|
|
71
|
+
if request.type in _NAME_IN_UPDATE_PATH:
|
|
72
|
+
endpoint = f"{endpoint}/{quote(request.name, safe='')}"
|
|
73
|
+
return endpoint
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _agree(explicit: str | None, from_request: str, name: str) -> str:
|
|
77
|
+
"""Use the request's value unless an explicit argument disagrees with it."""
|
|
78
|
+
if explicit is not None and explicit != from_request:
|
|
79
|
+
raise ValueError(
|
|
80
|
+
f"{name} argument {explicit!r} differs from the request's {from_request!r}"
|
|
81
|
+
)
|
|
82
|
+
return from_request
|
|
83
|
+
|
|
84
|
+
|
|
29
85
|
class DatasourceService:
|
|
30
86
|
"""Service for managing CodeMie Datasources."""
|
|
31
87
|
|
|
@@ -48,11 +104,7 @@ class DatasourceService:
|
|
|
48
104
|
Returns:
|
|
49
105
|
dict: Response from the server containing operation status
|
|
50
106
|
"""
|
|
51
|
-
|
|
52
|
-
endpoint = f"/v1/application/{request.project_name}/index"
|
|
53
|
-
else:
|
|
54
|
-
# All other datasources follow the same pattern
|
|
55
|
-
endpoint = f"/v1/index/knowledge_base/{request.type.name.lower()}"
|
|
107
|
+
endpoint = _create_endpoint(request)
|
|
56
108
|
|
|
57
109
|
return self._api.post(
|
|
58
110
|
endpoint,
|
|
@@ -145,10 +197,7 @@ class DatasourceService:
|
|
|
145
197
|
Returns:
|
|
146
198
|
dict: Response from the server containing operation status
|
|
147
199
|
"""
|
|
148
|
-
|
|
149
|
-
endpoint = f"/v1/application/{request.project_name}/index/{request.name}"
|
|
150
|
-
else:
|
|
151
|
-
endpoint = f"/v1/index/knowledge_base/{request.type.name.lower()}"
|
|
200
|
+
endpoint = _update_endpoint(request)
|
|
152
201
|
|
|
153
202
|
# Extract reindex params
|
|
154
203
|
params = {
|
|
@@ -270,28 +319,60 @@ class DatasourceService:
|
|
|
270
319
|
|
|
271
320
|
def create_provider_datasource(
|
|
272
321
|
self,
|
|
273
|
-
toolkit_id: str,
|
|
274
|
-
provider_name: str,
|
|
275
|
-
request:
|
|
322
|
+
toolkit_id: str | None = None,
|
|
323
|
+
provider_name: str | None = None,
|
|
324
|
+
request: (
|
|
325
|
+
CodeAnalysisDataSourceRequest
|
|
326
|
+
| CodeExplorationDataSourceRequest
|
|
327
|
+
| ProviderDataSourceRequest
|
|
328
|
+
| None
|
|
329
|
+
) = None,
|
|
276
330
|
) -> dict:
|
|
277
331
|
"""Create a provider-based datasource.
|
|
278
332
|
|
|
279
333
|
Args:
|
|
280
|
-
toolkit_id: ID of the toolkit to use
|
|
281
|
-
provider_name: Name of the provider
|
|
282
|
-
request: Provider datasource creation request (CodeAnalysisDataSourceRequest
|
|
334
|
+
toolkit_id: ID of the toolkit to use (taken from a ProviderDataSourceRequest if omitted)
|
|
335
|
+
provider_name: Name of the provider (taken from a ProviderDataSourceRequest if omitted)
|
|
336
|
+
request: Provider datasource creation request (CodeAnalysisDataSourceRequest,
|
|
337
|
+
CodeExplorationDataSourceRequest or ProviderDataSourceRequest)
|
|
283
338
|
|
|
284
339
|
Returns:
|
|
285
340
|
dict: Response from the server containing operation status
|
|
286
341
|
"""
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
)
|
|
342
|
+
if request is None:
|
|
343
|
+
raise ValueError("request is required")
|
|
344
|
+
if isinstance(request, ProviderDataSourceRequest):
|
|
345
|
+
toolkit_id = _agree(toolkit_id, request.toolkit_id, "toolkit_id")
|
|
346
|
+
provider_name = _agree(
|
|
347
|
+
provider_name, request.provider_name, "provider_name"
|
|
348
|
+
)
|
|
349
|
+
body = request.to_body()
|
|
350
|
+
else:
|
|
351
|
+
body = request.model_dump(by_alias=True, exclude_none=True)
|
|
352
|
+
if not toolkit_id or not provider_name:
|
|
353
|
+
raise ValueError("toolkit_id and provider_name are required")
|
|
354
|
+
query = urlencode({"toolkit_id": toolkit_id, "provider_name": provider_name})
|
|
355
|
+
endpoint = f"/v1/index/provider?{query}"
|
|
290
356
|
|
|
291
|
-
return self._api.post(
|
|
292
|
-
|
|
357
|
+
return self._api.post(endpoint, dict, json_data=body)
|
|
358
|
+
|
|
359
|
+
def update_provider_datasource(
|
|
360
|
+
self, index_info_id: str, request: UpdateProviderDataSourceRequest
|
|
361
|
+
) -> dict:
|
|
362
|
+
"""Update a provider-based datasource.
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
index_info_id: ID of the provider datasource
|
|
366
|
+
request: Update request; description and project_space_visible are
|
|
367
|
+
always sent, merged with the provider settings.
|
|
368
|
+
|
|
369
|
+
Returns:
|
|
370
|
+
dict: Response from the server containing operation status
|
|
371
|
+
"""
|
|
372
|
+
return self._api.put(
|
|
373
|
+
f"/v1/index/provider/{quote(index_info_id, safe='')}",
|
|
293
374
|
dict,
|
|
294
|
-
json_data=request.
|
|
375
|
+
json_data=request.to_body(),
|
|
295
376
|
)
|
|
296
377
|
|
|
297
378
|
def health_check(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codemie-sdk-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.707
|
|
4
4
|
Summary: CodeMie SDK for Python
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: CodeMie
|
|
@@ -539,6 +539,27 @@ Datasources can have the following statuses:
|
|
|
539
539
|
- `FETCHING`: Fetching data from source
|
|
540
540
|
- `IN_PROGRESS`: Processing/indexing in progress
|
|
541
541
|
|
|
542
|
+
#### Datasource Limitations
|
|
543
|
+
|
|
544
|
+
- **This SDK cannot rename or move a datasource.** An update addresses a datasource by its project and name
|
|
545
|
+
(provider datasources by their id), so the SDK has no way to change either; the platform supports a project
|
|
546
|
+
move, but the SDK does not expose it yet. A different name addresses a different datasource, or is not found.
|
|
547
|
+
The search index and any assistant that uses the datasource refer to it by that name, so they would stop
|
|
548
|
+
matching after a rename. To "rename", create a new datasource, point your assistants at it, then delete the
|
|
549
|
+
old one.
|
|
550
|
+
- **File datasources are not supported by the Infrastructure-as-Code tooling** built on this SDK. Creating
|
|
551
|
+
one needs the file contents uploaded together with the request, which a declarative document cannot carry.
|
|
552
|
+
Use `create_file_datasource(...)` with the files directly instead.
|
|
553
|
+
- **Some updates overwrite what they omit.** An SVN update is written in full by the platform, so
|
|
554
|
+
`UpdateSvnDataSourceRequest` requires the visibility flag (`shared_with_project`), `prompt`, `files_filter`
|
|
555
|
+
and `docs_generation`; pass the current values (`None` clears a nullable one). A SharePoint update with
|
|
556
|
+
`full_reindex=True` on an OAuth datasource (`oauth_codemie` / `oauth_custom`) needs `access_token`. An Xray
|
|
557
|
+
update does not take `embedding_model`: the platform sets it only on create.
|
|
558
|
+
- **SVN datasources are not found by `list(datasource_types=[DataSourceType.SVN])`.** `DataSourceType.SVN` only
|
|
559
|
+
selects the request route. The platform stores an SVN datasource with the index type you picked (`code`,
|
|
560
|
+
`summary` or `chunk-summary`) and `vcs_type="svn"`, so filtering by `SVN` returns an empty list. Filter by the
|
|
561
|
+
code index types and use `datasource.svn`, which is set only for SVN datasources, to tell them apart.
|
|
562
|
+
|
|
542
563
|
#### Best Practices for Datasources
|
|
543
564
|
|
|
544
565
|
1. **Naming Convention**:
|
|
@@ -4,7 +4,7 @@ codemie_sdk/auth/credentials.py,sha256=hO0X3EQWZSlIm0ABhiJo4fIIndm2blB0JZWMaWvsu
|
|
|
4
4
|
codemie_sdk/builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
codemie_sdk/builders/workflow/__init__.py,sha256=kQS-h9EiMiFWByZCElwv-X786AkVWdsa5ynXwoP_4hs,1605
|
|
6
6
|
codemie_sdk/builders/workflow/builder.py,sha256=bb_1uUe0AFhWuqe60Dao_1E-INxPwa7bzdwOprquuQg,13818
|
|
7
|
-
codemie_sdk/builders/workflow/definition.py,sha256=
|
|
7
|
+
codemie_sdk/builders/workflow/definition.py,sha256=jMLynQER2-mCyBNodO7bHceOxH2VneaxNtMc388W8ss,15206
|
|
8
8
|
codemie_sdk/builders/workflow/publish.py,sha256=wrXFDNX0LpRTULp8zm5DD6hEmAqEwIMxPm0mSs82xjQ,7370
|
|
9
9
|
codemie_sdk/client/__init__.py,sha256=yf6C39MmrJ6gK9ZHMhBeynKwUUYVSUTQbKxU8-4qpKg,101
|
|
10
10
|
codemie_sdk/client/client.py,sha256=J-PfxYNwB5XAU5d7BAVOaOGmOKM94bzvvf2Itrw6D7Y,10202
|
|
@@ -14,12 +14,12 @@ codemie_sdk/models/a2a.py,sha256=93GGBg4vkrlnuGCtakMLgYtrD9U54Dme9Dm5sJGO2bc,198
|
|
|
14
14
|
codemie_sdk/models/activity_event.py,sha256=KDEzzUEfs1J9ALNo4mLP-Rq7jeTM4g-P4A5A7Z4YjzM,1072
|
|
15
15
|
codemie_sdk/models/admin.py,sha256=2UGaO60ZrHHcDcV9thYBVxDyUCvtfPQhs10WswhGFJs,2298
|
|
16
16
|
codemie_sdk/models/analytics.py,sha256=B9lLAddL_LylXsoOukiPqbz4HVd2itmuB6iaEbhpKiQ,10194
|
|
17
|
-
codemie_sdk/models/assistant.py,sha256
|
|
17
|
+
codemie_sdk/models/assistant.py,sha256=-utLYHT1YkkUoWl_sktX14hGwHOCyhHbYildWeJOixs,28356
|
|
18
18
|
codemie_sdk/models/categories.py,sha256=eq7_sw-sevNLeWpjaW3N055Xcgbbevs0Bl_rj--maUk,2303
|
|
19
19
|
codemie_sdk/models/common.py,sha256=ipNNdQlv4Ct1UyIAknjJbrdjjvv0lZJYK6dnPm8wai4,1170
|
|
20
20
|
codemie_sdk/models/conversation.py,sha256=r5gV5BD-Euj4OfeLYn6NBiO-S6uFQtwACVobvFgLUcA,10204
|
|
21
21
|
codemie_sdk/models/cost_center.py,sha256=BAZMXAQj6QpEBXsN9tcXJt7LaHlFHBH_-wQV1D_ihBk,2359
|
|
22
|
-
codemie_sdk/models/datasource.py,sha256=
|
|
22
|
+
codemie_sdk/models/datasource.py,sha256=jp1Rbx1f0cvgUierU-3ru0xfq7NEpjaB_NBpp7VfCOk,31711
|
|
23
23
|
codemie_sdk/models/errors.py,sha256=tQXoPUhM2U95NoyTxsSSJws8PQ-Fr3iOQQ8IjJCsx78,11658
|
|
24
24
|
codemie_sdk/models/file_operation.py,sha256=h5UBCCAbQQGm1EavF0AHn_dNE2t_Cc9be20lv_K5Vo8,722
|
|
25
25
|
codemie_sdk/models/guardrails.py,sha256=813PRnu9VEF6hoUB-lw5xG_qAZXPic38qL40AwYkSMQ,2114
|
|
@@ -38,7 +38,7 @@ codemie_sdk/models/vendor_guardrail.py,sha256=dQtuFZXFUs_IUQlnPQth0Sd49Sx9gfDtkA
|
|
|
38
38
|
codemie_sdk/models/vendor_knowledgebase.py,sha256=fDj526KDJocx1Tn_B0uP3UQ5e89RMvesExFPwyeqME0,4996
|
|
39
39
|
codemie_sdk/models/vendor_runtime.py,sha256=CCFmBOV6vHgRvoD_5gRofqG41Wyxtdfy8DHcWkZ3Z5g,6179
|
|
40
40
|
codemie_sdk/models/vendor_workflow.py,sha256=ysu3anNa2xrSDvZb3zcTZ-_DGXcvJSUcmYIllDYceBo,4926
|
|
41
|
-
codemie_sdk/models/workflow.py,sha256=
|
|
41
|
+
codemie_sdk/models/workflow.py,sha256=VtO7bxjCiLwVclTbQ9-__AQx1QUAS3sKo1Z-qCfo94M,5551
|
|
42
42
|
codemie_sdk/models/workflow_execution_payload.py,sha256=0nhbiXyZlvbhB2SB6B_T6s2bOKruEVDlQsGan1Siw5U,1224
|
|
43
43
|
codemie_sdk/models/workflow_state.py,sha256=uP1yLYwPpgPc17xpLwjanvlRzK6zT9qMZR-fAkvwFGg,1322
|
|
44
44
|
codemie_sdk/models/workflow_thoughts.py,sha256=9fE380lMvC23fq677EI_JTk48Nf2jyPg3-mpj9VTx54,579
|
|
@@ -54,7 +54,7 @@ codemie_sdk/services/codemie_guardrails.py,sha256=O3yCeIQYG8W7z-sVRR4Cw9UVncqP9l
|
|
|
54
54
|
codemie_sdk/services/conversation.py,sha256=HWedtlrVXvq4xyAgVNzJ9IZSeHMx4Se5fyp8PPIloEQ,14809
|
|
55
55
|
codemie_sdk/services/cost_center.py,sha256=YewsrVyzIW9N68CaKgM58DB5reMBJQHljyNRxYeTRxM,4036
|
|
56
56
|
codemie_sdk/services/customer_config_service.py,sha256=XxPjiR9cf5M8qjHuRfovwiEAEk7OERJHLTuCAfBr7BU,4871
|
|
57
|
-
codemie_sdk/services/datasource.py,sha256=
|
|
57
|
+
codemie_sdk/services/datasource.py,sha256=4Glf8pyytMM0kZi41FBIjY_DVCa9brrVMIBAGtU230c,17314
|
|
58
58
|
codemie_sdk/services/dynamic_config.py,sha256=amgSOZ-835r6O_U72sjiFe60rrxJZqJ2L7oKCK-avE4,4214
|
|
59
59
|
codemie_sdk/services/files.py,sha256=ERb6irexO2hIKepUiTw498J0dt0427YNdKrXdcOu9tM,2762
|
|
60
60
|
codemie_sdk/services/integration.py,sha256=n4ggDedJ2GCI5mTgZNfrYE49uzLsp_BKYKMdTBKRX2s,9944
|
|
@@ -80,6 +80,6 @@ codemie_sdk/services/workflow_execution_state.py,sha256=u1xmGvaHjqvQS5ujhyvJ_Ac7
|
|
|
80
80
|
codemie_sdk/services/workspace.py,sha256=eLwZ0fhi1BfOesrXaQlTdOll8q7ENP9b_jb5eybKSVw,5038
|
|
81
81
|
codemie_sdk/utils/__init__.py,sha256=EzK_UrS5KHmAnE73Hci9LaObB5omjVUhIq4svh0gfwo,137
|
|
82
82
|
codemie_sdk/utils/http.py,sha256=PWejBKa5pwzQ5eLVhdN8lYKEu1B1QtwGTRmZfnGFL6c,14158
|
|
83
|
-
codemie_sdk_python-0.1.
|
|
84
|
-
codemie_sdk_python-0.1.
|
|
85
|
-
codemie_sdk_python-0.1.
|
|
83
|
+
codemie_sdk_python-0.1.707.dist-info/METADATA,sha256=HiCG6xXJOdLHDnEyuyEIaol9AvboQTB4MgJiSNXo_hs,49750
|
|
84
|
+
codemie_sdk_python-0.1.707.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
85
|
+
codemie_sdk_python-0.1.707.dist-info/RECORD,,
|
|
File without changes
|