codemie-sdk-python 0.1.222__py3-none-any.whl → 0.1.256__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/__init__.py +79 -3
- codemie_sdk/client/client.py +31 -3
- codemie_sdk/models/assistant.py +53 -0
- codemie_sdk/models/datasource.py +45 -0
- codemie_sdk/models/integration.py +1 -1
- codemie_sdk/models/vendor_guardrail.py +152 -0
- codemie_sdk/models/vendor_knowledgebase.py +151 -0
- codemie_sdk/models/vendor_workflow.py +145 -0
- codemie_sdk/models/workflow_execution_payload.py +6 -2
- codemie_sdk/services/assistant.py +214 -0
- codemie_sdk/services/datasource.py +67 -0
- codemie_sdk/services/files.py +21 -0
- codemie_sdk/services/{vendor.py → vendor_assistant.py} +13 -13
- codemie_sdk/services/vendor_guardrail.py +375 -0
- codemie_sdk/services/vendor_knowledgebase.py +270 -0
- codemie_sdk/services/vendor_workflow.py +330 -0
- codemie_sdk/services/workflow.py +10 -1
- codemie_sdk/services/workflow_execution.py +26 -4
- codemie_sdk/utils/http.py +21 -7
- {codemie_sdk_python-0.1.222.dist-info → codemie_sdk_python-0.1.256.dist-info}/METADATA +129 -9
- {codemie_sdk_python-0.1.222.dist-info → codemie_sdk_python-0.1.256.dist-info}/RECORD +22 -16
- {codemie_sdk_python-0.1.222.dist-info → codemie_sdk_python-0.1.256.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Models for vendor workflow settings."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from typing import Optional, List
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
|
+
|
|
9
|
+
from .vendor_assistant import PaginationInfo, TokenPagination
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class VendorWorkflowSetting(BaseModel):
|
|
13
|
+
"""Model representing a vendor workflow setting."""
|
|
14
|
+
|
|
15
|
+
model_config = ConfigDict(extra="ignore")
|
|
16
|
+
|
|
17
|
+
setting_id: str = Field(..., description="Unique identifier for the setting")
|
|
18
|
+
setting_name: str = Field(..., description="Name of the setting")
|
|
19
|
+
project: str = Field(..., description="Project associated with the setting")
|
|
20
|
+
entities: List[str] = Field(
|
|
21
|
+
default_factory=list, description="List of entities associated with the setting"
|
|
22
|
+
)
|
|
23
|
+
invalid: Optional[bool] = Field(None, description="Whether the setting is invalid")
|
|
24
|
+
error: Optional[str] = Field(
|
|
25
|
+
None, description="Error message if the setting is invalid"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class VendorWorkflowSettingsResponse(BaseModel):
|
|
30
|
+
"""Response model for vendor workflow settings list."""
|
|
31
|
+
|
|
32
|
+
model_config = ConfigDict(extra="ignore")
|
|
33
|
+
|
|
34
|
+
data: List[VendorWorkflowSetting] = Field(
|
|
35
|
+
..., description="List of vendor workflow settings"
|
|
36
|
+
)
|
|
37
|
+
pagination: PaginationInfo = Field(..., description="Pagination information")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class VendorWorkflowStatus(str, Enum):
|
|
41
|
+
"""Status of vendor workflow."""
|
|
42
|
+
|
|
43
|
+
PREPARED = "PREPARED"
|
|
44
|
+
NOT_PREPARED = "NOT_PREPARED"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class VendorWorkflow(BaseModel):
|
|
48
|
+
"""Model representing a vendor workflow."""
|
|
49
|
+
|
|
50
|
+
model_config = ConfigDict(extra="ignore")
|
|
51
|
+
|
|
52
|
+
id: str = Field(..., description="Unique identifier for the workflow")
|
|
53
|
+
name: str = Field(..., description="Name of the workflow")
|
|
54
|
+
status: VendorWorkflowStatus = Field(..., description="Status of the workflow")
|
|
55
|
+
description: Optional[str] = Field(None, description="Description of the workflow")
|
|
56
|
+
version: str = Field(..., description="Version of the workflow")
|
|
57
|
+
createdAt: datetime = Field(
|
|
58
|
+
..., description="Creation timestamp", alias="createdAt"
|
|
59
|
+
)
|
|
60
|
+
updatedAt: datetime = Field(
|
|
61
|
+
..., description="Last update timestamp", alias="updatedAt"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class VendorWorkflowsResponse(BaseModel):
|
|
66
|
+
"""Response model for vendor workflows list."""
|
|
67
|
+
|
|
68
|
+
model_config = ConfigDict(extra="ignore")
|
|
69
|
+
|
|
70
|
+
data: List[VendorWorkflow] = Field(..., description="List of vendor workflows")
|
|
71
|
+
pagination: TokenPagination = Field(
|
|
72
|
+
..., description="Token-based pagination information"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class VendorWorkflowAlias(BaseModel):
|
|
77
|
+
"""Model representing a vendor workflow alias."""
|
|
78
|
+
|
|
79
|
+
model_config = ConfigDict(extra="ignore")
|
|
80
|
+
|
|
81
|
+
id: str = Field(..., description="Unique identifier for the alias")
|
|
82
|
+
name: str = Field(..., description="Name of the alias")
|
|
83
|
+
status: VendorWorkflowStatus = Field(..., description="Status of the alias")
|
|
84
|
+
description: Optional[str] = Field(None, description="Description of the alias")
|
|
85
|
+
version: str = Field(..., description="Version of the alias")
|
|
86
|
+
createdAt: datetime = Field(
|
|
87
|
+
..., description="Creation timestamp", alias="createdAt"
|
|
88
|
+
)
|
|
89
|
+
updatedAt: datetime = Field(
|
|
90
|
+
..., description="Last update timestamp", alias="updatedAt"
|
|
91
|
+
)
|
|
92
|
+
aiRunId: Optional[str] = Field(
|
|
93
|
+
None, description="AI run ID if the alias is installed", alias="aiRunId"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class VendorWorkflowAliasesResponse(BaseModel):
|
|
98
|
+
"""Response model for vendor workflow aliases list."""
|
|
99
|
+
|
|
100
|
+
model_config = ConfigDict(extra="ignore")
|
|
101
|
+
|
|
102
|
+
data: List[VendorWorkflowAlias] = Field(
|
|
103
|
+
..., description="List of vendor workflow aliases"
|
|
104
|
+
)
|
|
105
|
+
pagination: TokenPagination = Field(
|
|
106
|
+
..., description="Token-based pagination information"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class VendorWorkflowInstallRequest(BaseModel):
|
|
111
|
+
"""Model for a single workflow installation request."""
|
|
112
|
+
|
|
113
|
+
model_config = ConfigDict(extra="ignore")
|
|
114
|
+
|
|
115
|
+
id: str = Field(..., description="Workflow ID to install")
|
|
116
|
+
flowAliasId: str = Field(..., description="Flow alias ID to use for the workflow")
|
|
117
|
+
setting_id: str = Field(..., description="Vendor setting ID")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class VendorWorkflowInstallSummary(BaseModel):
|
|
121
|
+
"""Model for workflow installation summary."""
|
|
122
|
+
|
|
123
|
+
model_config = ConfigDict(extra="ignore")
|
|
124
|
+
|
|
125
|
+
flowId: str = Field(..., description="Installed workflow ID")
|
|
126
|
+
flowAliasId: str = Field(..., description="Flow alias ID used for installation")
|
|
127
|
+
aiRunId: str = Field(..., description="AI run ID for the installation")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class VendorWorkflowInstallResponse(BaseModel):
|
|
131
|
+
"""Response model for workflow installation."""
|
|
132
|
+
|
|
133
|
+
model_config = ConfigDict(extra="ignore")
|
|
134
|
+
|
|
135
|
+
summary: List[VendorWorkflowInstallSummary] = Field(
|
|
136
|
+
..., description="List of installation summaries"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class VendorWorkflowUninstallResponse(BaseModel):
|
|
141
|
+
"""Response model for workflow uninstallation."""
|
|
142
|
+
|
|
143
|
+
model_config = ConfigDict(extra="ignore")
|
|
144
|
+
|
|
145
|
+
success: bool = Field(..., description="Whether the uninstallation was successful")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Workflow execution payload models."""
|
|
2
2
|
|
|
3
|
-
from typing import Optional
|
|
3
|
+
from typing import Optional, Union
|
|
4
4
|
from pydantic import BaseModel, ConfigDict, Field
|
|
5
5
|
|
|
6
6
|
|
|
@@ -9,9 +9,13 @@ class WorkflowExecutionCreateRequest(BaseModel):
|
|
|
9
9
|
|
|
10
10
|
model_config = ConfigDict(populate_by_name=True)
|
|
11
11
|
|
|
12
|
-
user_input: Optional[str] = Field(
|
|
12
|
+
user_input: Optional[Union[str, dict, list, int, float, bool]] = Field(
|
|
13
13
|
None, description="User input for the workflow execution"
|
|
14
14
|
)
|
|
15
15
|
file_name: Optional[str] = Field(
|
|
16
16
|
None, description="File name associated with the workflow execution"
|
|
17
17
|
)
|
|
18
|
+
propagate_headers: bool = Field(
|
|
19
|
+
default=False,
|
|
20
|
+
description="Enable propagation of X-* HTTP headers to MCP servers during tool execution",
|
|
21
|
+
)
|
|
@@ -170,16 +170,153 @@ class AssistantService:
|
|
|
170
170
|
"""
|
|
171
171
|
return self._api.get(f"/v1/assistants/prebuilt/{slug}", Assistant)
|
|
172
172
|
|
|
173
|
+
def list_versions(
|
|
174
|
+
self, assistant_id: str, page: int = 0, per_page: Optional[int] = None
|
|
175
|
+
):
|
|
176
|
+
"""List assistant versions.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
assistant_id: Assistant identifier
|
|
180
|
+
page: Page number for pagination
|
|
181
|
+
per_page: Items per page (optional). If not provided, backend defaults are used.
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
List of AssistantVersion objects
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
params: Dict[str, Any] = {"page": page}
|
|
188
|
+
if per_page is not None:
|
|
189
|
+
params["per_page"] = per_page
|
|
190
|
+
from ..models.assistant import AssistantVersion
|
|
191
|
+
|
|
192
|
+
raw = self._api.get(
|
|
193
|
+
f"/v1/assistants/{assistant_id}/versions",
|
|
194
|
+
dict,
|
|
195
|
+
params=params,
|
|
196
|
+
wrap_response=False,
|
|
197
|
+
)
|
|
198
|
+
items = []
|
|
199
|
+
if isinstance(raw, list):
|
|
200
|
+
items = raw
|
|
201
|
+
elif isinstance(raw, dict):
|
|
202
|
+
items = raw.get("data") or raw.get("versions") or []
|
|
203
|
+
else:
|
|
204
|
+
items = []
|
|
205
|
+
return [AssistantVersion.model_validate(it) for it in items]
|
|
206
|
+
|
|
207
|
+
def get_version(self, assistant_id: str, version_number: int):
|
|
208
|
+
"""Get a specific assistant version by number.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
assistant_id: Assistant identifier
|
|
212
|
+
version_number: Version number to retrieve
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
AssistantVersion object
|
|
216
|
+
"""
|
|
217
|
+
from ..models.assistant import AssistantVersion
|
|
218
|
+
|
|
219
|
+
raw = self._api.get(
|
|
220
|
+
f"/v1/assistants/{assistant_id}/versions/{version_number}", AssistantVersion
|
|
221
|
+
)
|
|
222
|
+
if isinstance(raw, dict):
|
|
223
|
+
return AssistantVersion.model_validate(raw)
|
|
224
|
+
return raw
|
|
225
|
+
|
|
226
|
+
def compare_versions(self, assistant_id: str, v1: int, v2: int) -> Dict[str, Any]:
|
|
227
|
+
"""Compare two assistant versions and return diff summary.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
assistant_id: Assistant identifier
|
|
231
|
+
v1: First version number
|
|
232
|
+
v2: Second version number
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
Generic dictionary with comparison result (diff, summary, etc.)
|
|
236
|
+
"""
|
|
237
|
+
return self._api.get(
|
|
238
|
+
f"/v1/assistants/{assistant_id}/versions/{v1}/compare/{v2}",
|
|
239
|
+
dict,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
def rollback_to_version(
|
|
243
|
+
self, assistant_id: str, version_number: int, change_notes: Optional[str] = None
|
|
244
|
+
) -> dict:
|
|
245
|
+
"""Rollback assistant to a specific version. Creates a new version mirroring target.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
assistant_id: Assistant identifier
|
|
249
|
+
version_number: Target version to rollback to
|
|
250
|
+
change_notes: Optional description of why rollback is performed
|
|
251
|
+
|
|
252
|
+
Returns:
|
|
253
|
+
Backend response (dict)
|
|
254
|
+
"""
|
|
255
|
+
payload: Dict[str, Any] = {}
|
|
256
|
+
if change_notes:
|
|
257
|
+
payload["change_notes"] = change_notes
|
|
258
|
+
try:
|
|
259
|
+
return self._api.post(
|
|
260
|
+
f"/v1/assistants/{assistant_id}/versions/{version_number}/rollback",
|
|
261
|
+
dict,
|
|
262
|
+
json_data=payload,
|
|
263
|
+
)
|
|
264
|
+
except requests.HTTPError as err:
|
|
265
|
+
try:
|
|
266
|
+
assistant = self.get(assistant_id)
|
|
267
|
+
version = self.get_version(assistant_id, version_number)
|
|
268
|
+
|
|
269
|
+
update_req = AssistantUpdateRequest(
|
|
270
|
+
name=assistant.name,
|
|
271
|
+
description=assistant.description or "",
|
|
272
|
+
system_prompt=version.system_prompt,
|
|
273
|
+
project=assistant.project,
|
|
274
|
+
llm_model_type=version.llm_model_type or assistant.llm_model_type,
|
|
275
|
+
temperature=version.temperature
|
|
276
|
+
if hasattr(version, "temperature")
|
|
277
|
+
else assistant.temperature,
|
|
278
|
+
top_p=version.top_p
|
|
279
|
+
if hasattr(version, "top_p")
|
|
280
|
+
else assistant.top_p,
|
|
281
|
+
context=version.context
|
|
282
|
+
if hasattr(version, "context")
|
|
283
|
+
else assistant.context,
|
|
284
|
+
toolkits=version.toolkits
|
|
285
|
+
if hasattr(version, "toolkits")
|
|
286
|
+
else assistant.toolkits,
|
|
287
|
+
user_prompts=assistant.user_prompts,
|
|
288
|
+
shared=assistant.shared,
|
|
289
|
+
is_react=assistant.is_react,
|
|
290
|
+
is_global=assistant.is_global,
|
|
291
|
+
slug=assistant.slug,
|
|
292
|
+
mcp_servers=version.mcp_servers
|
|
293
|
+
if hasattr(version, "mcp_servers")
|
|
294
|
+
else assistant.mcp_servers,
|
|
295
|
+
assistant_ids=version.assistant_ids
|
|
296
|
+
if hasattr(version, "assistant_ids")
|
|
297
|
+
else assistant.assistant_ids,
|
|
298
|
+
)
|
|
299
|
+
resp = self.update(assistant_id, update_req)
|
|
300
|
+
resp["_rollback_fallback"] = True
|
|
301
|
+
resp["_target_version"] = version_number
|
|
302
|
+
if change_notes:
|
|
303
|
+
resp["change_notes"] = change_notes
|
|
304
|
+
return resp
|
|
305
|
+
except Exception:
|
|
306
|
+
raise err
|
|
307
|
+
|
|
173
308
|
def chat(
|
|
174
309
|
self,
|
|
175
310
|
assistant_id: str,
|
|
176
311
|
request: AssistantChatRequest,
|
|
312
|
+
headers: Optional[Dict[str, str]] = None,
|
|
177
313
|
) -> Union[requests.Response, BaseModelResponse]:
|
|
178
314
|
"""Send a chat request to an assistant.
|
|
179
315
|
|
|
180
316
|
Args:
|
|
181
317
|
assistant_id: ID of the assistant to chat with
|
|
182
318
|
request: Chat request details
|
|
319
|
+
headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
|
|
183
320
|
|
|
184
321
|
Returns:
|
|
185
322
|
Chat response or streaming response
|
|
@@ -198,6 +335,7 @@ class AssistantService:
|
|
|
198
335
|
BaseModelResponse,
|
|
199
336
|
json_data=request.model_dump(exclude_none=True, by_alias=True),
|
|
200
337
|
stream=request.stream,
|
|
338
|
+
extra_headers=headers,
|
|
201
339
|
)
|
|
202
340
|
if not request.stream and pydantic_schema:
|
|
203
341
|
# we do conversion to the BaseModel here because self._parse_response don't see actual request model,
|
|
@@ -206,6 +344,82 @@ class AssistantService:
|
|
|
206
344
|
|
|
207
345
|
return response
|
|
208
346
|
|
|
347
|
+
def chat_with_version(
|
|
348
|
+
self,
|
|
349
|
+
assistant_id: str,
|
|
350
|
+
version_number: int,
|
|
351
|
+
request: AssistantChatRequest,
|
|
352
|
+
) -> Union[requests.Response, BaseModelResponse]:
|
|
353
|
+
"""Send a chat request to a specific assistant version.
|
|
354
|
+
|
|
355
|
+
Uses the stable chat endpoint with an explicit `version` parameter to
|
|
356
|
+
ensure compatibility with environments that don't expose
|
|
357
|
+
/versions/{version}/model.
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
assistant_id: ID of the assistant to chat with
|
|
361
|
+
version_number: version to pin chat to
|
|
362
|
+
request: Chat request details
|
|
363
|
+
|
|
364
|
+
Returns:
|
|
365
|
+
Chat response or streaming response
|
|
366
|
+
"""
|
|
367
|
+
pydantic_schema = None
|
|
368
|
+
if issubclass(request.output_schema, BaseModel):
|
|
369
|
+
pydantic_schema = deepcopy(request.output_schema)
|
|
370
|
+
request.output_schema = request.output_schema.model_json_schema()
|
|
371
|
+
|
|
372
|
+
payload = request.model_dump(exclude_none=True, by_alias=True)
|
|
373
|
+
payload["version"] = version_number
|
|
374
|
+
|
|
375
|
+
response = self._api.post(
|
|
376
|
+
f"/v1/assistants/{assistant_id}/model",
|
|
377
|
+
BaseModelResponse,
|
|
378
|
+
json_data=payload,
|
|
379
|
+
stream=request.stream,
|
|
380
|
+
)
|
|
381
|
+
if not request.stream and pydantic_schema:
|
|
382
|
+
response.generated = pydantic_schema.model_validate(response.generated)
|
|
383
|
+
|
|
384
|
+
return response
|
|
385
|
+
|
|
386
|
+
def chat_by_slug(
|
|
387
|
+
self,
|
|
388
|
+
assistant_slug: str,
|
|
389
|
+
request: AssistantChatRequest,
|
|
390
|
+
headers: Optional[Dict[str, str]] = None,
|
|
391
|
+
) -> Union[requests.Response, BaseModelResponse]:
|
|
392
|
+
"""Send a chat request to an assistant by slug.
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
assistant_slug: Slug of the assistant to chat with
|
|
396
|
+
request: Chat request details
|
|
397
|
+
headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
|
|
398
|
+
|
|
399
|
+
Returns:
|
|
400
|
+
Chat response or streaming response
|
|
401
|
+
"""
|
|
402
|
+
pydantic_schema = None
|
|
403
|
+
if (
|
|
404
|
+
request.output_schema is not None
|
|
405
|
+
and inspect.isclass(request.output_schema)
|
|
406
|
+
and issubclass(request.output_schema, BaseModel)
|
|
407
|
+
):
|
|
408
|
+
pydantic_schema = deepcopy(request.output_schema)
|
|
409
|
+
request.output_schema = request.output_schema.model_json_schema()
|
|
410
|
+
|
|
411
|
+
response = self._api.post(
|
|
412
|
+
f"/v1/assistants/slug/{assistant_slug}/model",
|
|
413
|
+
BaseModelResponse,
|
|
414
|
+
json_data=request.model_dump(exclude_none=True, by_alias=True),
|
|
415
|
+
stream=request.stream,
|
|
416
|
+
extra_headers=headers,
|
|
417
|
+
)
|
|
418
|
+
if not request.stream and pydantic_schema:
|
|
419
|
+
response.generated = pydantic_schema.model_validate(response.generated)
|
|
420
|
+
|
|
421
|
+
return response
|
|
422
|
+
|
|
209
423
|
def upload_file_to_chat(self, file_path: Path):
|
|
210
424
|
"""Upload a file to assistant chat and return the response containing file_url."""
|
|
211
425
|
|
|
@@ -15,7 +15,11 @@ from ..models.datasource import (
|
|
|
15
15
|
UpdateCodeDataSourceRequest,
|
|
16
16
|
BaseUpdateDataSourceRequest,
|
|
17
17
|
FileDataSourceRequest,
|
|
18
|
+
CodeAnalysisDataSourceRequest,
|
|
19
|
+
CodeExplorationDataSourceRequest,
|
|
20
|
+
ElasticsearchStatsResponse,
|
|
18
21
|
)
|
|
22
|
+
from ..models.assistant import AssistantListResponse
|
|
19
23
|
from ..utils import ApiRequestHandler
|
|
20
24
|
|
|
21
25
|
|
|
@@ -206,3 +210,66 @@ class DatasourceService:
|
|
|
206
210
|
Deletion confirmation
|
|
207
211
|
"""
|
|
208
212
|
return self._api.delete(f"/v1/index/{datasource_id}", dict)
|
|
213
|
+
|
|
214
|
+
def get_assistants_using_datasource(
|
|
215
|
+
self, datasource_id: str
|
|
216
|
+
) -> List[AssistantListResponse]:
|
|
217
|
+
"""Get list of assistants that are using this datasource.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
datasource_id: ID of the datasource
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
List of AssistantListResponse objects containing assistants using this datasource
|
|
224
|
+
|
|
225
|
+
Raises:
|
|
226
|
+
ApiError: If the datasource is not found or other API errors occur.
|
|
227
|
+
"""
|
|
228
|
+
return self._api.get(
|
|
229
|
+
f"/v1/index/{datasource_id}/assistants", List[AssistantListResponse]
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
def create_provider_datasource(
|
|
233
|
+
self,
|
|
234
|
+
toolkit_id: str,
|
|
235
|
+
provider_name: str,
|
|
236
|
+
request: Union[CodeAnalysisDataSourceRequest, CodeExplorationDataSourceRequest],
|
|
237
|
+
) -> dict:
|
|
238
|
+
"""Create a provider-based datasource.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
toolkit_id: ID of the toolkit to use
|
|
242
|
+
provider_name: Name of the provider
|
|
243
|
+
request: Provider datasource creation request (CodeAnalysisDataSourceRequest or CodeExplorationDataSourceRequest)
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
dict: Response from the server containing operation status
|
|
247
|
+
"""
|
|
248
|
+
endpoint = (
|
|
249
|
+
f"/v1/index/provider?toolkit_id={toolkit_id}&provider_name={provider_name}"
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
return self._api.post(
|
|
253
|
+
endpoint,
|
|
254
|
+
dict,
|
|
255
|
+
json_data=request.model_dump(by_alias=True, exclude_none=True),
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
def get_elasticsearch_stats(self, datasource_id: str) -> ElasticsearchStatsResponse:
|
|
259
|
+
"""Get Elasticsearch statistics for a specific datasource index.
|
|
260
|
+
|
|
261
|
+
Args:
|
|
262
|
+
datasource_id: ID of the datasource
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
ElasticsearchStatsResponse with Elasticsearch statistics including:
|
|
266
|
+
- index_name: Name of the index in Elasticsearch
|
|
267
|
+
- size_in_bytes: Size of the index in bytes
|
|
268
|
+
|
|
269
|
+
Raises:
|
|
270
|
+
ApiError: If the datasource is not found, platform datasources are not supported,
|
|
271
|
+
or Elasticsearch statistics are not available.
|
|
272
|
+
"""
|
|
273
|
+
return self._api.get(
|
|
274
|
+
f"/v1/index/{datasource_id}/elasticsearch", ElasticsearchStatsResponse
|
|
275
|
+
)
|
codemie_sdk/services/files.py
CHANGED
|
@@ -59,3 +59,24 @@ class FileOperationService:
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
return response
|
|
62
|
+
|
|
63
|
+
def get_file(self, file_id: str) -> bytes:
|
|
64
|
+
"""Get a file by its ID.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
file_id: The file identifier (base64 encoded ID from file_url)
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
bytes: The file content as binary data
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
ApiError: If the file doesn't exist or there's an API error
|
|
74
|
+
"""
|
|
75
|
+
import requests
|
|
76
|
+
|
|
77
|
+
response = self._api.get(
|
|
78
|
+
f"/v1/files/{file_id}",
|
|
79
|
+
response_model=requests.Response,
|
|
80
|
+
wrap_response=False,
|
|
81
|
+
)
|
|
82
|
+
return response.content
|
|
@@ -16,7 +16,7 @@ from ..models.vendor_assistant import (
|
|
|
16
16
|
from ..utils import ApiRequestHandler
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class
|
|
19
|
+
class VendorAssistantService:
|
|
20
20
|
"""Service for managing cloud vendor assistant settings (AWS, Azure, GCP)."""
|
|
21
21
|
|
|
22
22
|
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
@@ -47,9 +47,9 @@ class VendorService:
|
|
|
47
47
|
|
|
48
48
|
Example:
|
|
49
49
|
>>> # Using enum
|
|
50
|
-
>>> settings = client.
|
|
50
|
+
>>> settings = client.vendor_assistants.get_assistant_settings(VendorType.AWS, page=0, per_page=10)
|
|
51
51
|
>>> # Using string
|
|
52
|
-
>>> settings = client.
|
|
52
|
+
>>> settings = client.vendor_assistants.get_assistant_settings("aws", page=0, per_page=10)
|
|
53
53
|
"""
|
|
54
54
|
# Convert enum to string value if needed
|
|
55
55
|
vendor_str = vendor.value if isinstance(vendor, VendorType) else vendor
|
|
@@ -86,14 +86,14 @@ class VendorService:
|
|
|
86
86
|
|
|
87
87
|
Example:
|
|
88
88
|
>>> # Get first page
|
|
89
|
-
>>> assistants = client.
|
|
89
|
+
>>> assistants = client.vendor_assistants.get_assistants(
|
|
90
90
|
... vendor=VendorType.AWS,
|
|
91
91
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
|
|
92
92
|
... per_page=8
|
|
93
93
|
... )
|
|
94
94
|
>>> # Get next page if available
|
|
95
95
|
>>> if assistants.pagination.next_token:
|
|
96
|
-
... next_page = client.
|
|
96
|
+
... next_page = client.vendor_assistants.get_assistants(
|
|
97
97
|
... vendor=VendorType.AWS,
|
|
98
98
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
|
|
99
99
|
... per_page=8,
|
|
@@ -135,7 +135,7 @@ class VendorService:
|
|
|
135
135
|
VendorAssistant containing assistant details
|
|
136
136
|
|
|
137
137
|
Example:
|
|
138
|
-
>>> assistant = client.
|
|
138
|
+
>>> assistant = client.vendor_assistants.get_assistant(
|
|
139
139
|
... vendor=VendorType.AWS,
|
|
140
140
|
... assistant_id="TJBKR0DGWT",
|
|
141
141
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
|
|
@@ -176,7 +176,7 @@ class VendorService:
|
|
|
176
176
|
instruction, foundation model, and timestamps
|
|
177
177
|
|
|
178
178
|
Example:
|
|
179
|
-
>>> version_details = client.
|
|
179
|
+
>>> version_details = client.vendor_assistants.get_assistant_version(
|
|
180
180
|
... vendor=VendorType.AWS,
|
|
181
181
|
... assistant_id="TJBKR0DGWT",
|
|
182
182
|
... version="1",
|
|
@@ -223,7 +223,7 @@ class VendorService:
|
|
|
223
223
|
|
|
224
224
|
Example:
|
|
225
225
|
>>> # Get first page of aliases
|
|
226
|
-
>>> aliases = client.
|
|
226
|
+
>>> aliases = client.vendor_assistants.get_assistant_aliases(
|
|
227
227
|
... vendor=VendorType.AWS,
|
|
228
228
|
... assistant_id="TJBKR0DGWT",
|
|
229
229
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
|
|
@@ -233,7 +233,7 @@ class VendorService:
|
|
|
233
233
|
... print(f"{alias.name} (v{alias.version}): {alias.status}")
|
|
234
234
|
>>> # Get next page if available
|
|
235
235
|
>>> if aliases.pagination.next_token:
|
|
236
|
-
... next_page = client.
|
|
236
|
+
... next_page = client.vendor_assistants.get_assistant_aliases(
|
|
237
237
|
... vendor=VendorType.AWS,
|
|
238
238
|
... assistant_id="TJBKR0DGWT",
|
|
239
239
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
|
|
@@ -281,7 +281,7 @@ class VendorService:
|
|
|
281
281
|
... agentAliasId="MNULODIW4N",
|
|
282
282
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
|
|
283
283
|
... )
|
|
284
|
-
>>> response = client.
|
|
284
|
+
>>> response = client.vendor_assistants.install_assistants(
|
|
285
285
|
... vendor=VendorType.AWS,
|
|
286
286
|
... assistants=[install_request]
|
|
287
287
|
... )
|
|
@@ -301,7 +301,7 @@ class VendorService:
|
|
|
301
301
|
... setting_id="SETTING_ID"
|
|
302
302
|
... )
|
|
303
303
|
... ]
|
|
304
|
-
>>> response = client.
|
|
304
|
+
>>> response = client.vendor_assistants.install_assistants(
|
|
305
305
|
... vendor=VendorType.AWS,
|
|
306
306
|
... assistants=requests
|
|
307
307
|
... )
|
|
@@ -340,14 +340,14 @@ class VendorService:
|
|
|
340
340
|
... agentAliasId="MNULODIW4N",
|
|
341
341
|
... setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c"
|
|
342
342
|
... )
|
|
343
|
-
>>> install_response = client.
|
|
343
|
+
>>> install_response = client.vendor_assistants.install_assistants(
|
|
344
344
|
... vendor=VendorType.AWS,
|
|
345
345
|
... assistants=[install_request]
|
|
346
346
|
... )
|
|
347
347
|
>>> ai_run_id = install_response.summary[0].aiRunId
|
|
348
348
|
>>>
|
|
349
349
|
>>> # Later, uninstall the assistant using the AI run ID
|
|
350
|
-
>>> response = client.
|
|
350
|
+
>>> response = client.vendor_assistants.uninstall_assistant(
|
|
351
351
|
... vendor=VendorType.AWS,
|
|
352
352
|
... ai_run_id=ai_run_id
|
|
353
353
|
... )
|