codemie-sdk-python 0.1.92__py3-none-any.whl → 0.1.258__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.
Potentially problematic release.
This version of codemie-sdk-python might be problematic. Click here for more details.
- codemie_sdk/__init__.py +114 -2
- codemie_sdk/auth/credentials.py +5 -4
- codemie_sdk/client/client.py +66 -5
- codemie_sdk/models/assistant.py +111 -8
- codemie_sdk/models/conversation.py +169 -0
- codemie_sdk/models/datasource.py +80 -1
- codemie_sdk/models/file_operation.py +25 -0
- codemie_sdk/models/integration.py +3 -1
- codemie_sdk/models/vendor_assistant.py +187 -0
- 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.py +1 -1
- codemie_sdk/models/workflow_execution_payload.py +21 -0
- codemie_sdk/models/workflow_state.py +6 -3
- codemie_sdk/models/workflow_thoughts.py +26 -0
- codemie_sdk/services/assistant.py +220 -1
- codemie_sdk/services/conversation.py +90 -0
- codemie_sdk/services/datasource.py +67 -0
- codemie_sdk/services/files.py +82 -0
- codemie_sdk/services/vendor_assistant.py +364 -0
- 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/webhook.py +41 -0
- codemie_sdk/services/workflow.py +26 -2
- codemie_sdk/services/workflow_execution.py +54 -6
- codemie_sdk/utils/http.py +43 -16
- codemie_sdk_python-0.1.258.dist-info/METADATA +1404 -0
- codemie_sdk_python-0.1.258.dist-info/RECORD +45 -0
- codemie_sdk_python-0.1.92.dist-info/METADATA +0 -892
- codemie_sdk_python-0.1.92.dist-info/RECORD +0 -30
- {codemie_sdk_python-0.1.92.dist-info → codemie_sdk_python-0.1.258.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1404 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: codemie-sdk-python
|
|
3
|
+
Version: 0.1.258
|
|
4
|
+
Summary: CodeMie SDK for Python
|
|
5
|
+
Author: Vadym Vlasenko
|
|
6
|
+
Author-email: vadym_vlasenko@epam.com
|
|
7
|
+
Requires-Python: >=3.12,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Requires-Dist: pydantic (>=2.12.2,<3.0.0)
|
|
11
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# CodeMie Python SDK
|
|
15
|
+
|
|
16
|
+
Python SDK for CodeMie services. This SDK provides a comprehensive interface to interact with CodeMie services, including LLM (Large Language Models), assistants, workflows, and tools.
|
|
17
|
+
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [Basic Usage](#basic-usage)
|
|
23
|
+
- [Service Details](#service-details)
|
|
24
|
+
- [LLM Service](#llm-service)
|
|
25
|
+
- [Assistant Service](#assistant-service)
|
|
26
|
+
- [Core Methods](#core-methods)
|
|
27
|
+
- [Advanced Features](#advanced-features)
|
|
28
|
+
- [Prompt Variables Support](#prompt-variables-support)
|
|
29
|
+
- [Assistant Versioning](#assistant-versioning)
|
|
30
|
+
- [Datasource Service](#datasource-service)
|
|
31
|
+
- [Supported Datasource Types](#supported-datasource-types)
|
|
32
|
+
- [Core Methods](#core-methods-1)
|
|
33
|
+
- [Datasource Status](#datasource-status)
|
|
34
|
+
- [Best Practices for Datasources](#best-practices-for-datasources)
|
|
35
|
+
- [Integration Service](#integration-service)
|
|
36
|
+
- [Integration Types](#integration-types)
|
|
37
|
+
- [Core Methods](#core-methods-2)
|
|
38
|
+
- [Best Practices for Integrations](#best-practices-for-integrations)
|
|
39
|
+
- [Workflow Service](#workflow-service)
|
|
40
|
+
- [Core Methods](#core-methods-3)
|
|
41
|
+
- [Workflow Execution](#workflow-execution)
|
|
42
|
+
- [Workflow Configuration](#workflow-configuration)
|
|
43
|
+
- [Best Practices](#best-practices)
|
|
44
|
+
- [Error Handling](#error-handling)
|
|
45
|
+
- [Workflow Status Monitoring](#workflow-status-monitoring)
|
|
46
|
+
- [Conversation Service](#conversation-service)
|
|
47
|
+
- [Core Methods](#core-methods-4)
|
|
48
|
+
- [File Service](#file-service)
|
|
49
|
+
- [Core Methods](#core-methods-5)
|
|
50
|
+
- [User Service](#user-service)
|
|
51
|
+
- [Core Methods](#core-methods-6)
|
|
52
|
+
- [Task Service](#task-service)
|
|
53
|
+
- [Core Methods](#core-methods-7)
|
|
54
|
+
- [Webhook Service](#webhook-service)
|
|
55
|
+
- [Core Methods](#core-methods-8)
|
|
56
|
+
- [Vendor Services](#vendor-services)
|
|
57
|
+
- [Vendor Assistant Service](#vendor-assistant-service)
|
|
58
|
+
- [Vendor Workflow Service](#vendor-workflow-service)
|
|
59
|
+
- [Vendor Knowledge Base Service](#vendor-knowledge-base-service)
|
|
60
|
+
- [Vendor Guardrail Service](#vendor-guardrail-service)
|
|
61
|
+
- [Error Handling](#error-handling-1)
|
|
62
|
+
- [Authentication](#authentication)
|
|
63
|
+
- [Required Parameters](#required-parameters)
|
|
64
|
+
- [Usage Examples](#usage-examples)
|
|
65
|
+
- [Best Practices](#best-practices-1)
|
|
66
|
+
- [Support](#support)
|
|
67
|
+
- [Development](#development)
|
|
68
|
+
- [Setup](#setup)
|
|
69
|
+
- [Code Quality](#code-quality)
|
|
70
|
+
- [Building Package](#building-package)
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pip install codemie-sdk-python
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
### Basic usage
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from codemie_sdk import CodeMieClient
|
|
84
|
+
|
|
85
|
+
# Initialize client with authentication parameters
|
|
86
|
+
client = CodeMieClient(
|
|
87
|
+
auth_server_url="https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth",
|
|
88
|
+
auth_client_id="your-client-id",
|
|
89
|
+
auth_client_secret="your-client-secret",
|
|
90
|
+
auth_realm_name="your-realm",
|
|
91
|
+
codemie_api_domain="https://codemie.lab.epam.com/code-assistant-api"
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Service Details
|
|
96
|
+
|
|
97
|
+
### LLM Service
|
|
98
|
+
|
|
99
|
+
The LLM service provides access to language models and embedding models.
|
|
100
|
+
|
|
101
|
+
**Available Methods:**
|
|
102
|
+
|
|
103
|
+
1. **list()** - Retrieves a list of available LLM models
|
|
104
|
+
2. **list_embeddings()** - Retrieves a list of available embedding models
|
|
105
|
+
|
|
106
|
+
Each LLM model contains:
|
|
107
|
+
- Model identifier
|
|
108
|
+
- Model capabilities
|
|
109
|
+
- Configuration parameters
|
|
110
|
+
|
|
111
|
+
**Example:**
|
|
112
|
+
```python
|
|
113
|
+
# List available LLM models
|
|
114
|
+
llm_models = client.llms.list()
|
|
115
|
+
|
|
116
|
+
# List available embedding models
|
|
117
|
+
embedding_models = client.llms.list_embeddings()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Assistant Service
|
|
121
|
+
|
|
122
|
+
The Assistant service allows you to manage and interact with CodeMie assistants:
|
|
123
|
+
|
|
124
|
+
#### Core Methods
|
|
125
|
+
|
|
126
|
+
1. **List Assistants**
|
|
127
|
+
```python
|
|
128
|
+
assistants = client.assistants.list(
|
|
129
|
+
minimal_response=True, # Return minimal assistant info
|
|
130
|
+
scope="visible_to_user", # or "created_by_user"
|
|
131
|
+
page=0,
|
|
132
|
+
per_page=12,
|
|
133
|
+
filters={"key": "value"} # Optional filters
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
2. **Get Assistant Details**
|
|
138
|
+
```python
|
|
139
|
+
# By ID
|
|
140
|
+
assistant = client.assistants.get("assistant-id")
|
|
141
|
+
|
|
142
|
+
# By Slug
|
|
143
|
+
assistant = client.assistants.get_by_slug("assistant-slug")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
3. **Create Assistant**
|
|
147
|
+
```python
|
|
148
|
+
from codemie_sdk.models.assistant import AssistantCreateRequest
|
|
149
|
+
|
|
150
|
+
request = AssistantCreateRequest(
|
|
151
|
+
name="My Assistant",
|
|
152
|
+
description="Assistant description",
|
|
153
|
+
instructions="Assistant instructions",
|
|
154
|
+
tools=["tool1", "tool2"],
|
|
155
|
+
# Additional parameters as needed
|
|
156
|
+
)
|
|
157
|
+
new_assistant = client.assistants.create(request)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
4. **Update Assistant**
|
|
161
|
+
```python
|
|
162
|
+
from codemie_sdk.models.assistant import AssistantUpdateRequest
|
|
163
|
+
|
|
164
|
+
request = AssistantUpdateRequest(
|
|
165
|
+
name="Updated Name",
|
|
166
|
+
description="Updated description",
|
|
167
|
+
# Other fields to update
|
|
168
|
+
)
|
|
169
|
+
updated_assistant = client.assistants.update("assistant-id", request)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
5. **Delete Assistant**
|
|
173
|
+
```python
|
|
174
|
+
result = client.assistants.delete("assistant-id")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### Advanced Features
|
|
178
|
+
|
|
179
|
+
6. **Chat with Assistant (with MCP header propagation)**
|
|
180
|
+
```python
|
|
181
|
+
from codemie_sdk.models.assistant import AssistantChatRequest
|
|
182
|
+
|
|
183
|
+
chat_request = AssistantChatRequest(
|
|
184
|
+
text="Your message here",
|
|
185
|
+
stream=False, # Set to True for streaming response
|
|
186
|
+
propagate_headers=True, # Enable propagation of X-* headers to MCP servers
|
|
187
|
+
)
|
|
188
|
+
# Pass X-* headers to forward to MCP servers
|
|
189
|
+
response = client.assistants.chat(
|
|
190
|
+
"assistant-id",
|
|
191
|
+
chat_request,
|
|
192
|
+
headers={
|
|
193
|
+
"X-Tenant-ID": "tenant-abc-123",
|
|
194
|
+
"X-User-ID": "user-456",
|
|
195
|
+
"X-Request-ID": "req-123",
|
|
196
|
+
},
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
7. **Chat with Assistant by slug (with MCP header propagation)**
|
|
201
|
+
```python
|
|
202
|
+
chat_request = AssistantChatRequest(
|
|
203
|
+
text="Your message here",
|
|
204
|
+
propagate_headers=True,
|
|
205
|
+
)
|
|
206
|
+
response = client.assistants.chat_by_slug(
|
|
207
|
+
"assistant-slug",
|
|
208
|
+
chat_request,
|
|
209
|
+
headers={
|
|
210
|
+
"X-Environment": "production",
|
|
211
|
+
"X-Feature-Flag-Beta": "true",
|
|
212
|
+
},
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
8. **Utilize structured outputs with Assistant**
|
|
217
|
+
```python
|
|
218
|
+
from pydantic import BaseModel
|
|
219
|
+
|
|
220
|
+
class OutputSchema(BaseModel):
|
|
221
|
+
requirements: list[str]
|
|
222
|
+
|
|
223
|
+
chat_request = AssistantChatRequest(
|
|
224
|
+
text="Your message here",
|
|
225
|
+
stream=False,
|
|
226
|
+
output_schema=OutputSchema,
|
|
227
|
+
# Additional parameters
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
response = client.assistants.chat("id", chat_request)
|
|
231
|
+
# response.generated is a Pydantic object
|
|
232
|
+
```
|
|
233
|
+
Or using JSON schema in dict format
|
|
234
|
+
```python
|
|
235
|
+
output_schema = {
|
|
236
|
+
"properties": {
|
|
237
|
+
"requirements": {
|
|
238
|
+
"items": {"type": "string"},
|
|
239
|
+
"title": "Requirements",
|
|
240
|
+
"type": "array",
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"required": ["requirements"],
|
|
244
|
+
"title": "OutputSchema",
|
|
245
|
+
"type": "object",
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
chat_request = AssistantChatRequest(
|
|
249
|
+
text="Your message here",
|
|
250
|
+
stream=False,
|
|
251
|
+
output_schema=output_schema,
|
|
252
|
+
# Additional parameters
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
response = client.assistants.chat("id", chat_request)
|
|
256
|
+
# response.generated is a dict corresponding to the JSON schema
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
9. **Work with Prebuilt Assistants**
|
|
260
|
+
```python
|
|
261
|
+
# List prebuilt assistants
|
|
262
|
+
prebuilt = client.assistants.get_prebuilt()
|
|
263
|
+
|
|
264
|
+
# Get specific prebuilt assistant
|
|
265
|
+
prebuilt_assistant = client.assistants.get_prebuilt_by_slug("assistant-slug")
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
10. **Get Available Tools**
|
|
269
|
+
```python
|
|
270
|
+
tools = client.assistants.get_tools()
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### Prompt Variables Support
|
|
274
|
+
|
|
275
|
+
The SDK supports assistant-level prompt variables that the backend already exposes via the `prompt_variables` field.
|
|
276
|
+
|
|
277
|
+
Create and update an assistant with prompt variables:
|
|
278
|
+
```python
|
|
279
|
+
from codemie_sdk.models.assistant import AssistantCreateRequest, AssistantUpdateRequest, PromptVariable
|
|
280
|
+
|
|
281
|
+
# Create
|
|
282
|
+
create_req = AssistantCreateRequest(
|
|
283
|
+
name="My Assistant",
|
|
284
|
+
description="Assistant description",
|
|
285
|
+
system_prompt="Instructions. Use {{project_name}} in responses.",
|
|
286
|
+
toolkits=[],
|
|
287
|
+
project="my_project",
|
|
288
|
+
llm_model_type="gpt-4o",
|
|
289
|
+
context=[],
|
|
290
|
+
conversation_starters=[],
|
|
291
|
+
mcp_servers=[],
|
|
292
|
+
assistant_ids=[],
|
|
293
|
+
prompt_variables=[
|
|
294
|
+
PromptVariable(key="project_name", default_value="Delta", description="Current project"),
|
|
295
|
+
PromptVariable(key="region", default_value="eu"),
|
|
296
|
+
],
|
|
297
|
+
)
|
|
298
|
+
client.assistants.create(create_req)
|
|
299
|
+
|
|
300
|
+
# Update
|
|
301
|
+
update_req = AssistantUpdateRequest(
|
|
302
|
+
**create_req.model_dump(),
|
|
303
|
+
prompt_variables=[
|
|
304
|
+
PromptVariable(key="project_name", default_value="Delta-Updated"),
|
|
305
|
+
PromptVariable(key="region", default_value="us"),
|
|
306
|
+
],
|
|
307
|
+
)
|
|
308
|
+
client.assistants.update("assistant-id", update_req)
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### Assistant Versioning
|
|
312
|
+
|
|
313
|
+
The SDK provides full assistant versioning capabilities.
|
|
314
|
+
|
|
315
|
+
1. **List Versions**
|
|
316
|
+
```python
|
|
317
|
+
# Get all versions of an assistant
|
|
318
|
+
versions = client.assistants.list_versions("assistant-id", page=0, per_page=20)
|
|
319
|
+
for version in versions:
|
|
320
|
+
print(f"Version {version.version_number}")
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
2. **Get Specific Version**
|
|
324
|
+
```python
|
|
325
|
+
# Get details of a specific version
|
|
326
|
+
version = client.assistants.get_version("assistant-id", version_number=2)
|
|
327
|
+
print(version.system_prompt)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
3. **Compare Versions**
|
|
331
|
+
```python
|
|
332
|
+
from codemie_sdk.models.assistant import AssistantVersionDiff
|
|
333
|
+
|
|
334
|
+
# Compare two versions to see what changed
|
|
335
|
+
diff = client.assistants.compare_versions("assistant-id", version1=1, version2=3)
|
|
336
|
+
print(diff.summary)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
4. **Rollback to Version**
|
|
340
|
+
```python
|
|
341
|
+
# Rollback assistant to a previous version
|
|
342
|
+
response = client.assistants.rollback_to_version("assistant-id", version_number=2)
|
|
343
|
+
print(f"Rolled back to version {response.version_number}")
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
5. **Chat with Specific Version**
|
|
347
|
+
```python
|
|
348
|
+
from codemie_sdk.models.assistant import AssistantChatRequest
|
|
349
|
+
|
|
350
|
+
# Chat with a specific version of the assistant
|
|
351
|
+
request = AssistantChatRequest(text="Hi", stream=False)
|
|
352
|
+
response = client.assistants.chat_with_version("assistant-id", version_number=2, request)
|
|
353
|
+
print(response.generated)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Datasource Service
|
|
357
|
+
|
|
358
|
+
The Datasource service enables managing various types of data sources in CodeMie, including code repositories, Confluence spaces, Jira projects, files, and Google documents.
|
|
359
|
+
|
|
360
|
+
#### Supported Datasource Types
|
|
361
|
+
|
|
362
|
+
- `CODE`: Code repository datasources
|
|
363
|
+
- `CONFLUENCE`: Confluence knowledge base
|
|
364
|
+
- `JIRA`: Jira knowledge base
|
|
365
|
+
- `FILE`: File-based knowledge base
|
|
366
|
+
- `GOOGLE`: Google documents
|
|
367
|
+
- `AZURE_DEVOPS_WIKI`: Azure DevOps Wiki knowledge base (requires Azure DevOps integration)
|
|
368
|
+
|
|
369
|
+
#### Core Methods
|
|
370
|
+
|
|
371
|
+
1. **Create Datasource**
|
|
372
|
+
```python
|
|
373
|
+
from codemie_sdk.models.datasource import (
|
|
374
|
+
CodeDataSourceRequest,
|
|
375
|
+
ConfluenceDataSourceRequest,
|
|
376
|
+
JiraDataSourceRequest,
|
|
377
|
+
GoogleDataSourceRequest,
|
|
378
|
+
AzureDevOpsWikiDataSourceRequest
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
# Create Code Datasource
|
|
382
|
+
code_request = CodeDataSourceRequest(
|
|
383
|
+
name="my_repo", # lowercase letters and underscores only
|
|
384
|
+
project_name="my_project",
|
|
385
|
+
description="My code repository",
|
|
386
|
+
link="https://github.com/user/repo",
|
|
387
|
+
branch="main",
|
|
388
|
+
index_type="code", # or "summary" or "chunk-summary"
|
|
389
|
+
files_filter="*.py", # optional
|
|
390
|
+
embeddings_model="model_name",
|
|
391
|
+
summarization_model="gpt-4", # optional
|
|
392
|
+
docs_generation=False # optional
|
|
393
|
+
)
|
|
394
|
+
result = client.datasources.create(code_request)
|
|
395
|
+
|
|
396
|
+
# Create Confluence Datasource
|
|
397
|
+
confluence_request = ConfluenceDataSourceRequest(
|
|
398
|
+
name="confluence_kb",
|
|
399
|
+
project_name="my_project",
|
|
400
|
+
description="Confluence space",
|
|
401
|
+
cql="space = 'MYSPACE'",
|
|
402
|
+
include_restricted_content=False,
|
|
403
|
+
include_archived_content=False,
|
|
404
|
+
include_attachments=True,
|
|
405
|
+
include_comments=True
|
|
406
|
+
)
|
|
407
|
+
result = client.datasources.create(confluence_request)
|
|
408
|
+
|
|
409
|
+
# Create Jira Datasource
|
|
410
|
+
jira_request = JiraDataSourceRequest(
|
|
411
|
+
name="jira_kb",
|
|
412
|
+
project_name="my_project",
|
|
413
|
+
description="Jira project",
|
|
414
|
+
jql="project = 'MYPROJECT'"
|
|
415
|
+
)
|
|
416
|
+
result = client.datasources.create(jira_request)
|
|
417
|
+
|
|
418
|
+
# Create Google Doc Datasource
|
|
419
|
+
google_request = GoogleDataSourceRequest(
|
|
420
|
+
name="google_doc",
|
|
421
|
+
project_name="my_project",
|
|
422
|
+
description="Google document",
|
|
423
|
+
google_doc="document_url"
|
|
424
|
+
)
|
|
425
|
+
result = client.datasources.create(google_request)
|
|
426
|
+
|
|
427
|
+
# Create Azure DevOps Wiki Datasource
|
|
428
|
+
# Note: Requires Azure DevOps integration to be configured
|
|
429
|
+
ado_wiki_request = AzureDevOpsWikiDataSourceRequest(
|
|
430
|
+
name="ado_wiki",
|
|
431
|
+
project_name="my_project",
|
|
432
|
+
description="Azure DevOps Wiki",
|
|
433
|
+
setting_id="azure-devops-integration-id", # Integration ID with ADO credentials
|
|
434
|
+
wiki_query="*", # Path filter (see wiki_query format below)
|
|
435
|
+
wiki_name="MyProject.wiki" # Optional: specific wiki name (leave empty for all wikis)
|
|
436
|
+
)
|
|
437
|
+
result = client.datasources.create(ado_wiki_request)
|
|
438
|
+
|
|
439
|
+
# Important: wiki_query Path Format
|
|
440
|
+
# The page path should NOT include "/Overview/Wiki" and must start from the page level.
|
|
441
|
+
#
|
|
442
|
+
# Example: If your Azure DevOps breadcrumbs show:
|
|
443
|
+
# "ProjectName/WikiName/Overview/Wiki/Page1/Page2"
|
|
444
|
+
#
|
|
445
|
+
# Then use: "/Page1/*" as the path
|
|
446
|
+
#
|
|
447
|
+
# Build the path using breadcrumb values, NOT the page URL.
|
|
448
|
+
#
|
|
449
|
+
# Common patterns:
|
|
450
|
+
# - "*" - Index all pages in the wiki
|
|
451
|
+
# - "/Engineering/*" - Index all pages under /Engineering folder
|
|
452
|
+
# - "/Engineering/Architecture" - Index only the Architecture page
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
2. **Update Datasource**
|
|
456
|
+
```python
|
|
457
|
+
from codemie_sdk.models.datasource import UpdateCodeDataSourceRequest, UpdateAzureDevOpsWikiDataSourceRequest
|
|
458
|
+
|
|
459
|
+
# Update Code Datasource
|
|
460
|
+
update_request = UpdateCodeDataSourceRequest(
|
|
461
|
+
name="my_repo",
|
|
462
|
+
project_name="my_project",
|
|
463
|
+
description="Updated description",
|
|
464
|
+
branch="develop",
|
|
465
|
+
full_reindex=True, # optional reindex parameters
|
|
466
|
+
skip_reindex=False,
|
|
467
|
+
resume_indexing=False
|
|
468
|
+
)
|
|
469
|
+
result = client.datasources.update("datasource_id", update_request)
|
|
470
|
+
|
|
471
|
+
# Update Azure DevOps Wiki Datasource
|
|
472
|
+
ado_update_request = UpdateAzureDevOpsWikiDataSourceRequest(
|
|
473
|
+
name="ado_wiki",
|
|
474
|
+
project_name="my_project",
|
|
475
|
+
description="Updated description",
|
|
476
|
+
wiki_query="/Engineering/*", # Update path filter (see wiki_query format above)
|
|
477
|
+
wiki_name="MyProject.wiki",
|
|
478
|
+
full_reindex=True # Trigger full reindex
|
|
479
|
+
)
|
|
480
|
+
result = client.datasources.update("datasource_id", ado_update_request)
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**Reindex Options for Azure DevOps Wiki:**
|
|
484
|
+
Azure DevOps Wiki datasources support the following reindex options:
|
|
485
|
+
- `full_reindex=True` - Completely reindex all pages (clears existing data and reindexes)
|
|
486
|
+
- `skip_reindex=True` - Update metadata without reindexing content
|
|
487
|
+
|
|
488
|
+
Note: Azure DevOps Wiki does not support `incremental_reindex` or `resume_indexing` options.
|
|
489
|
+
|
|
490
|
+
3. **List Datasources**
|
|
491
|
+
```python
|
|
492
|
+
# List all datasources with filtering and pagination
|
|
493
|
+
datasources = client.datasources.list(
|
|
494
|
+
page=0,
|
|
495
|
+
per_page=10,
|
|
496
|
+
sort_key="update_date", # or "date"
|
|
497
|
+
sort_order="desc", # or "asc"
|
|
498
|
+
datasource_types=["CODE", "CONFLUENCE", "AZURE_DEVOPS_WIKI"], # optional filter by type
|
|
499
|
+
projects=["project1", "project2"], # optional filter by projects
|
|
500
|
+
owner="John Doe", # optional filter by owner
|
|
501
|
+
status="COMPLETED" # optional filter by status
|
|
502
|
+
)
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
4. **Get Datasource Details**
|
|
506
|
+
```python
|
|
507
|
+
# Get single datasource by ID
|
|
508
|
+
datasource = client.datasources.get("datasource_id")
|
|
509
|
+
|
|
510
|
+
# Access Azure DevOps Wiki specific fields
|
|
511
|
+
if datasource.type == "knowledge_base_azure_devops_wiki":
|
|
512
|
+
wiki_info = datasource.azure_devops_wiki
|
|
513
|
+
if wiki_info:
|
|
514
|
+
print(f"Wiki Query: {wiki_info.wiki_query}")
|
|
515
|
+
print(f"Wiki Name: {wiki_info.wiki_name}")
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
5. **Delete Datasource**
|
|
519
|
+
```python
|
|
520
|
+
# Delete datasource by ID
|
|
521
|
+
result = client.datasources.delete("datasource_id")
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
#### Datasource Status
|
|
525
|
+
|
|
526
|
+
Datasources can have the following statuses:
|
|
527
|
+
- `COMPLETED`: Indexing completed successfully
|
|
528
|
+
- `FAILED`: Indexing failed
|
|
529
|
+
- `FETCHING`: Fetching data from source
|
|
530
|
+
- `IN_PROGRESS`: Processing/indexing in progress
|
|
531
|
+
|
|
532
|
+
#### Best Practices for Datasources
|
|
533
|
+
|
|
534
|
+
1. **Naming Convention**:
|
|
535
|
+
- Use lowercase letters and underscores for datasource names
|
|
536
|
+
- Keep names descriptive but concise
|
|
537
|
+
|
|
538
|
+
2. **Performance Optimization**:
|
|
539
|
+
- Use appropriate filters when listing datasources
|
|
540
|
+
- Consider pagination for large result sets
|
|
541
|
+
- Choose appropriate reindex options based on your needs
|
|
542
|
+
|
|
543
|
+
3. **Error Handling**:
|
|
544
|
+
- Always check datasource status after creation/update
|
|
545
|
+
- Handle potential failures gracefully
|
|
546
|
+
- Monitor processing information for issues
|
|
547
|
+
|
|
548
|
+
4. **Security**:
|
|
549
|
+
- Be careful with sensitive data in filters and queries
|
|
550
|
+
- Use proper access controls when sharing datasources
|
|
551
|
+
- Regularly review and clean up unused datasources
|
|
552
|
+
|
|
553
|
+
### Integration Service
|
|
554
|
+
|
|
555
|
+
The Integration service manages both user and project-level integrations in CodeMie, allowing you to configure and manage various integration settings.
|
|
556
|
+
|
|
557
|
+
#### Integration Types
|
|
558
|
+
|
|
559
|
+
- `USER`: User-level integrations
|
|
560
|
+
- `PROJECT`: Project-level integrations
|
|
561
|
+
|
|
562
|
+
#### Core Methods
|
|
563
|
+
|
|
564
|
+
1. **List Integrations**
|
|
565
|
+
```python
|
|
566
|
+
from codemie_sdk.models.integration import IntegrationType
|
|
567
|
+
|
|
568
|
+
# List user integrations with pagination
|
|
569
|
+
user_integrations = client.integrations.list(
|
|
570
|
+
setting_type=IntegrationType.USER,
|
|
571
|
+
page=0,
|
|
572
|
+
per_page=10,
|
|
573
|
+
filters={"some_filter": "value"} # optional
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
# List project integrations
|
|
577
|
+
project_integrations = client.integrations.list(
|
|
578
|
+
setting_type=IntegrationType.PROJECT,
|
|
579
|
+
per_page=100
|
|
580
|
+
)
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
2. **Get Integration**
|
|
584
|
+
```python
|
|
585
|
+
# Get integration by ID
|
|
586
|
+
integration = client.integrations.get(
|
|
587
|
+
integration_id="integration_id",
|
|
588
|
+
setting_type=IntegrationType.USER
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
# Get integration by alias
|
|
592
|
+
integration = client.integrations.get_by_alias(
|
|
593
|
+
alias="integration_alias",
|
|
594
|
+
setting_type=IntegrationType.PROJECT
|
|
595
|
+
)
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
3. **Create Integration**
|
|
599
|
+
```python
|
|
600
|
+
from codemie_sdk.models.integration import Integration
|
|
601
|
+
|
|
602
|
+
# Create new integration
|
|
603
|
+
new_integration = Integration(
|
|
604
|
+
setting_type=IntegrationType.USER,
|
|
605
|
+
alias="my_integration",
|
|
606
|
+
# Add other required fields based on integration type
|
|
607
|
+
)
|
|
608
|
+
result = client.integrations.create(new_integration)
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
4. **Update Integration**
|
|
612
|
+
```python
|
|
613
|
+
# Update existing integration
|
|
614
|
+
updated_integration = Integration(
|
|
615
|
+
setting_type=IntegrationType.USER,
|
|
616
|
+
alias="updated_alias",
|
|
617
|
+
# Add other fields to update
|
|
618
|
+
)
|
|
619
|
+
result = client.integrations.update("integration_id", updated_integration)
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
5. **Delete Integration**
|
|
623
|
+
```python
|
|
624
|
+
# Delete integration
|
|
625
|
+
result = client.integrations.delete(
|
|
626
|
+
setting_id="integration_id",
|
|
627
|
+
setting_type=IntegrationType.USER
|
|
628
|
+
)
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
#### Best Practices for Integrations
|
|
632
|
+
|
|
633
|
+
1. **Error Handling**:
|
|
634
|
+
- Handle `NotFoundError` when getting integrations by ID or alias
|
|
635
|
+
- Validate integration settings before creation/update
|
|
636
|
+
- Use appropriate setting type (USER/PROJECT) based on context
|
|
637
|
+
|
|
638
|
+
2. **Performance**:
|
|
639
|
+
- Use pagination for listing integrations
|
|
640
|
+
- Cache frequently accessed integrations when appropriate
|
|
641
|
+
- Use filters to reduce result set size
|
|
642
|
+
|
|
643
|
+
3. **Security**:
|
|
644
|
+
- Keep integration credentials secure
|
|
645
|
+
- Regularly review and update integration settings
|
|
646
|
+
- Use project-level integrations for team-wide settings
|
|
647
|
+
- Use user-level integrations for personal settings
|
|
648
|
+
|
|
649
|
+
### Workflow Service
|
|
650
|
+
|
|
651
|
+
The Workflow service enables you to create, manage, and execute workflows in CodeMie. Workflows allow you to automate complex processes and integrate various CodeMie services.
|
|
652
|
+
|
|
653
|
+
#### Core Methods
|
|
654
|
+
|
|
655
|
+
1. **Create Workflow**
|
|
656
|
+
```python
|
|
657
|
+
from codemie_sdk.models.workflow import WorkflowCreateRequest
|
|
658
|
+
|
|
659
|
+
# Create new workflow
|
|
660
|
+
workflow_request = WorkflowCreateRequest(
|
|
661
|
+
name="My Workflow",
|
|
662
|
+
description="Workflow description",
|
|
663
|
+
project="project-id",
|
|
664
|
+
yaml_config="your-yaml-configuration",
|
|
665
|
+
mode="SEQUENTIAL", # Optional, defaults to SEQUENTIAL
|
|
666
|
+
shared=False, # Optional, defaults to False
|
|
667
|
+
icon_url="https://example.com/icon.png" # Optional
|
|
668
|
+
)
|
|
669
|
+
result = client.workflows.create_workflow(workflow_request)
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
2. **Update Workflow**
|
|
673
|
+
```python
|
|
674
|
+
from codemie_sdk.models.workflow import WorkflowUpdateRequest
|
|
675
|
+
|
|
676
|
+
# Update existing workflow
|
|
677
|
+
update_request = WorkflowUpdateRequest(
|
|
678
|
+
name="Updated Workflow",
|
|
679
|
+
description="Updated description",
|
|
680
|
+
yaml_config="updated-yaml-config",
|
|
681
|
+
mode="PARALLEL",
|
|
682
|
+
shared=True
|
|
683
|
+
)
|
|
684
|
+
result = client.workflows.update("workflow-id", update_request)
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
3. **List Workflows**
|
|
688
|
+
```python
|
|
689
|
+
# List workflows with pagination and filtering
|
|
690
|
+
workflows = client.workflows.list(
|
|
691
|
+
page=0,
|
|
692
|
+
per_page=10,
|
|
693
|
+
projects=["project1", "project2"] # Optional project filter
|
|
694
|
+
)
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
4. **Get Workflow Details**
|
|
698
|
+
```python
|
|
699
|
+
# Get workflow by ID
|
|
700
|
+
workflow = client.workflows.get("workflow-id")
|
|
701
|
+
|
|
702
|
+
# Get prebuilt workflows
|
|
703
|
+
prebuilt_workflows = client.workflows.get_prebuilt()
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
5. **Delete Workflow**
|
|
707
|
+
```python
|
|
708
|
+
result = client.workflows.delete("workflow-id")
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
#### Workflow Execution
|
|
712
|
+
|
|
713
|
+
The SDK provides comprehensive workflow execution management through the WorkflowExecutionService:
|
|
714
|
+
|
|
715
|
+
1. **Run Workflow (with MCP header propagation)**
|
|
716
|
+
```python
|
|
717
|
+
# Enable propagation in payload and pass X-* headers to forward to MCP servers
|
|
718
|
+
execution = client.workflows.run(
|
|
719
|
+
"workflow-id",
|
|
720
|
+
user_input="optional input",
|
|
721
|
+
propagate_headers=True,
|
|
722
|
+
headers={
|
|
723
|
+
"X-Request-ID": "req-abc-123",
|
|
724
|
+
"X-Source-App": "analytics-ui",
|
|
725
|
+
},
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
# Get execution service for advanced operations
|
|
729
|
+
execution_service = client.workflows.executions("workflow-id")
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
2. **Manage Executions**
|
|
733
|
+
```python
|
|
734
|
+
# List workflow executions
|
|
735
|
+
executions = execution_service.list(
|
|
736
|
+
page=0,
|
|
737
|
+
per_page=10
|
|
738
|
+
)
|
|
739
|
+
|
|
740
|
+
# Get execution details
|
|
741
|
+
execution = execution_service.get("execution-id")
|
|
742
|
+
|
|
743
|
+
# Abort running execution
|
|
744
|
+
result = execution_service.abort("execution-id")
|
|
745
|
+
|
|
746
|
+
# Resume interrupted execution with header propagation (query param + headers)
|
|
747
|
+
result = execution_service.resume(
|
|
748
|
+
"execution-id",
|
|
749
|
+
propagate_headers=True,
|
|
750
|
+
headers={
|
|
751
|
+
"X-Correlation-ID": "corr-456",
|
|
752
|
+
},
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
# Delete all executions
|
|
756
|
+
result = execution_service.delete_all()
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
3. **Work with Execution States**
|
|
760
|
+
```python
|
|
761
|
+
# Get execution states
|
|
762
|
+
states = execution_service.states(execution_id).list()
|
|
763
|
+
|
|
764
|
+
# Get state output
|
|
765
|
+
state_output = execution_service.states(execution_id).get_output(state_id)
|
|
766
|
+
|
|
767
|
+
# Example of monitoring workflow with state verification
|
|
768
|
+
def verify_workflow_execution(execution_service, execution_id):
|
|
769
|
+
execution = execution_service.get(execution_id)
|
|
770
|
+
|
|
771
|
+
if execution.status == ExecutionStatus.SUCCEEDED:
|
|
772
|
+
# Get and verify states
|
|
773
|
+
states = execution_service.states(execution_id).list()
|
|
774
|
+
|
|
775
|
+
# States are ordered by completion date
|
|
776
|
+
if len(states) >= 2:
|
|
777
|
+
first_state = states[0]
|
|
778
|
+
second_state = states[1]
|
|
779
|
+
assert first_state.completed_at < second_state.completed_at
|
|
780
|
+
|
|
781
|
+
# Get state outputs
|
|
782
|
+
for state in states:
|
|
783
|
+
output = execution_service.states(execution_id).get_output(state.id)
|
|
784
|
+
print(f"State {state.id} output: {output.output}")
|
|
785
|
+
|
|
786
|
+
elif execution.status == ExecutionStatus.FAILED:
|
|
787
|
+
print(f"Workflow failed: {execution.error_message}")
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
#### Workflow Configuration
|
|
791
|
+
|
|
792
|
+
Workflows support various configuration options:
|
|
793
|
+
|
|
794
|
+
1. **Modes**:
|
|
795
|
+
- `SEQUENTIAL`: Tasks execute in sequence
|
|
796
|
+
- `PARALLEL`: Tasks can execute simultaneously
|
|
797
|
+
|
|
798
|
+
2. **YAML Configuration**:
|
|
799
|
+
```yaml
|
|
800
|
+
name: Example Workflow
|
|
801
|
+
description: Workflow description
|
|
802
|
+
tasks:
|
|
803
|
+
- name: task1
|
|
804
|
+
type: llm
|
|
805
|
+
config:
|
|
806
|
+
prompt: "Your prompt here"
|
|
807
|
+
model: "gpt-4"
|
|
808
|
+
|
|
809
|
+
- name: task2
|
|
810
|
+
type: tool
|
|
811
|
+
config:
|
|
812
|
+
tool_name: "your-tool"
|
|
813
|
+
parameters:
|
|
814
|
+
param1: "value1"
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
#### Best Practices
|
|
818
|
+
|
|
819
|
+
1. **Workflow Design**:
|
|
820
|
+
- Keep workflows modular and focused
|
|
821
|
+
- Use clear, descriptive names for workflows and tasks
|
|
822
|
+
- Document workflow purpose and requirements
|
|
823
|
+
- Test workflows thoroughly before deployment
|
|
824
|
+
|
|
825
|
+
2. **Execution Management**:
|
|
826
|
+
- Monitor long-running workflows
|
|
827
|
+
- Implement proper error handling
|
|
828
|
+
- Use pagination for listing executions
|
|
829
|
+
- Clean up completed executions regularly
|
|
830
|
+
|
|
831
|
+
3. **Performance Optimization**:
|
|
832
|
+
- Choose appropriate workflow mode (SEQUENTIAL/PARALLEL)
|
|
833
|
+
- Manage resource usage in parallel workflows
|
|
834
|
+
- Consider task dependencies and ordering
|
|
835
|
+
- Use efficient task configurations
|
|
836
|
+
|
|
837
|
+
4. **Security**:
|
|
838
|
+
- Control workflow sharing carefully
|
|
839
|
+
- Validate user inputs
|
|
840
|
+
- Manage sensitive data appropriately
|
|
841
|
+
- Regular audit of workflow access
|
|
842
|
+
|
|
843
|
+
5. **Maintenance**:
|
|
844
|
+
- Regular review of workflow configurations
|
|
845
|
+
- Update workflows when dependencies change
|
|
846
|
+
- Monitor workflow performance
|
|
847
|
+
- Archive or remove unused workflows
|
|
848
|
+
|
|
849
|
+
#### Error Handling
|
|
850
|
+
|
|
851
|
+
Implement proper error handling for workflow operations:
|
|
852
|
+
|
|
853
|
+
```python
|
|
854
|
+
try:
|
|
855
|
+
workflow = client.workflows.get("workflow-id")
|
|
856
|
+
except ApiError as e:
|
|
857
|
+
if e.status_code == 404:
|
|
858
|
+
print("Workflow not found")
|
|
859
|
+
else:
|
|
860
|
+
print(f"API error: {e}")
|
|
861
|
+
except Exception as e:
|
|
862
|
+
print(f"Unexpected error: {e}")
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
#### Workflow Status Monitoring
|
|
866
|
+
|
|
867
|
+
Monitor workflow execution status:
|
|
868
|
+
|
|
869
|
+
```python
|
|
870
|
+
def monitor_execution(execution_service, execution_id):
|
|
871
|
+
while True:
|
|
872
|
+
execution = execution_service.get(execution_id)
|
|
873
|
+
status = execution.status
|
|
874
|
+
|
|
875
|
+
if status == "COMPLETED":
|
|
876
|
+
print("Workflow completed successfully")
|
|
877
|
+
break
|
|
878
|
+
elif status == "FAILED":
|
|
879
|
+
print(f"Workflow failed: {execution.error}")
|
|
880
|
+
break
|
|
881
|
+
elif status == "ABORTED":
|
|
882
|
+
print("Workflow was aborted")
|
|
883
|
+
break
|
|
884
|
+
|
|
885
|
+
time.sleep(5) # Poll every 5 seconds
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
### Conversation Service
|
|
889
|
+
|
|
890
|
+
The Conversation service provides access to manage user conversations within CodeMie Assistants.
|
|
891
|
+
|
|
892
|
+
#### Core Methods
|
|
893
|
+
|
|
894
|
+
1. **Get All Conversations**
|
|
895
|
+
```python
|
|
896
|
+
# List all conversations for current user
|
|
897
|
+
conversations = client.conversations.list()
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
2. **Get Specific Conversation**
|
|
901
|
+
```python
|
|
902
|
+
# Get Conversation by it's ID
|
|
903
|
+
client.conversations.get_conversation("conversation-id")
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
3. **Get Conversation by Assistant ID**
|
|
907
|
+
```python
|
|
908
|
+
# Get Conversation where Assistant ID is present
|
|
909
|
+
client.conversations.list_by_assistant_id("assistant-id")
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
4. **Delete Conversation**
|
|
913
|
+
```python
|
|
914
|
+
# Delete specific conversation
|
|
915
|
+
client.conversations.delete("conversation-id")
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
### File Service
|
|
920
|
+
|
|
921
|
+
The File service enables file upload and download operations in CodeMie.
|
|
922
|
+
|
|
923
|
+
#### Core Methods
|
|
924
|
+
|
|
925
|
+
1. **Bulk Upload Files**
|
|
926
|
+
```python
|
|
927
|
+
from pathlib import Path
|
|
928
|
+
|
|
929
|
+
# Upload multiple files
|
|
930
|
+
files = [
|
|
931
|
+
Path("/path/to/file1.pdf"),
|
|
932
|
+
Path("/path/to/file2.txt"),
|
|
933
|
+
Path("/path/to/file3.docx")
|
|
934
|
+
]
|
|
935
|
+
|
|
936
|
+
response = client.files.bulk_upload(files)
|
|
937
|
+
|
|
938
|
+
# Access uploaded file information
|
|
939
|
+
for file_info in response.files:
|
|
940
|
+
print(f"Uploaded: {file_info.name}, ID: {file_info.id}")
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
2. **Get File**
|
|
944
|
+
```python
|
|
945
|
+
# Download file by ID
|
|
946
|
+
file_content = client.files.get_file("file-id")
|
|
947
|
+
|
|
948
|
+
# Save to disk
|
|
949
|
+
with open("downloaded_file.pdf", "wb") as f:
|
|
950
|
+
f.write(file_content)
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### User Service
|
|
954
|
+
|
|
955
|
+
The User service provides access to user profile and preferences.
|
|
956
|
+
|
|
957
|
+
#### Core Methods
|
|
958
|
+
|
|
959
|
+
1. **Get Current User Profile**
|
|
960
|
+
```python
|
|
961
|
+
# Get current user information
|
|
962
|
+
user = client.users.about_me()
|
|
963
|
+
print(f"User: {user.name}, Email: {user.email}")
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
2. **Get User Data and Preferences**
|
|
967
|
+
```python
|
|
968
|
+
# Get user data and preferences
|
|
969
|
+
user_data = client.users.get_data()
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
### Task Service
|
|
973
|
+
|
|
974
|
+
The Task service enables monitoring of background tasks.
|
|
975
|
+
|
|
976
|
+
#### Core Methods
|
|
977
|
+
|
|
978
|
+
1. **Get Background Task**
|
|
979
|
+
```python
|
|
980
|
+
# Get background task status by ID
|
|
981
|
+
task = client.tasks.get("task-id")
|
|
982
|
+
print(f"Task Status: {task.status}")
|
|
983
|
+
print(f"Progress: {task.progress}")
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
### Webhook Service
|
|
987
|
+
|
|
988
|
+
The Webhook service provides access to trigger available webhooks in CodeMie.
|
|
989
|
+
|
|
990
|
+
#### Core Methods
|
|
991
|
+
|
|
992
|
+
1. **Trigger Webhook**
|
|
993
|
+
```python
|
|
994
|
+
# Trigger assistant/workflow/datasource by its ID
|
|
995
|
+
# Data - body of the post method
|
|
996
|
+
response = client.webhook.trigger("resource_id", {"key": "value"})
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
### Vendor Services
|
|
1000
|
+
|
|
1001
|
+
The Vendor Services enable integration with cloud providers to access and manage their native AI assistants, workflows, knowledge bases, and guardrails. Currently, only AWS is supported.
|
|
1002
|
+
|
|
1003
|
+
#### Vendor Assistant Service
|
|
1004
|
+
|
|
1005
|
+
Manage cloud vendor assistants (AWS Bedrock Agents).
|
|
1006
|
+
|
|
1007
|
+
**Core Methods:**
|
|
1008
|
+
|
|
1009
|
+
1. **Get Assistant Settings**
|
|
1010
|
+
```python
|
|
1011
|
+
from codemie_sdk.models.vendor_assistant import VendorType
|
|
1012
|
+
|
|
1013
|
+
# Get AWS assistant settings with pagination
|
|
1014
|
+
settings = client.vendor_assistants.get_assistant_settings(
|
|
1015
|
+
vendor=VendorType.AWS,
|
|
1016
|
+
page=0,
|
|
1017
|
+
per_page=10
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
# Or use string
|
|
1021
|
+
settings = client.vendor_assistants.get_assistant_settings("aws", page=0, per_page=10)
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
2. **Get Assistants**
|
|
1025
|
+
```python
|
|
1026
|
+
# Get assistants for a specific vendor setting
|
|
1027
|
+
assistants = client.vendor_assistants.get_assistants(
|
|
1028
|
+
vendor=VendorType.AWS,
|
|
1029
|
+
setting_id="cac90788-39b7-4ffe-8b57-e8b047fa1f6c",
|
|
1030
|
+
per_page=8,
|
|
1031
|
+
next_token=None # For pagination
|
|
1032
|
+
)
|
|
1033
|
+
|
|
1034
|
+
# Access assistant data
|
|
1035
|
+
for assistant in assistants.data:
|
|
1036
|
+
print(f"Assistant: {assistant.name}, ID: {assistant.id}")
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
3. **Get Assistant Details**
|
|
1040
|
+
```python
|
|
1041
|
+
# Get specific assistant
|
|
1042
|
+
assistant = client.vendor_assistants.get_assistant(
|
|
1043
|
+
vendor=VendorType.AWS,
|
|
1044
|
+
setting_id="setting-id",
|
|
1045
|
+
assistant_id="assistant-id"
|
|
1046
|
+
)
|
|
1047
|
+
|
|
1048
|
+
# Get assistant versions
|
|
1049
|
+
versions = client.vendor_assistants.get_assistant_versions(
|
|
1050
|
+
vendor=VendorType.AWS,
|
|
1051
|
+
setting_id="setting-id",
|
|
1052
|
+
assistant_id="assistant-id"
|
|
1053
|
+
)
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
4. **Get Assistant Aliases**
|
|
1057
|
+
```python
|
|
1058
|
+
# Get aliases for an assistant
|
|
1059
|
+
aliases = client.vendor_assistants.get_assistant_aliases(
|
|
1060
|
+
vendor=VendorType.AWS,
|
|
1061
|
+
setting_id="setting-id",
|
|
1062
|
+
assistant_id="assistant-id"
|
|
1063
|
+
)
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
5. **Install/Uninstall Assistants**
|
|
1067
|
+
```python
|
|
1068
|
+
from codemie_sdk.models.vendor_assistant import VendorAssistantInstallRequest
|
|
1069
|
+
|
|
1070
|
+
# Install assistant
|
|
1071
|
+
install_request = VendorAssistantInstallRequest(
|
|
1072
|
+
assistant_id="assistant-id",
|
|
1073
|
+
version="1.0",
|
|
1074
|
+
project="project-name"
|
|
1075
|
+
)
|
|
1076
|
+
|
|
1077
|
+
response = client.vendor_assistants.install_assistant(
|
|
1078
|
+
vendor=VendorType.AWS,
|
|
1079
|
+
setting_id="setting-id",
|
|
1080
|
+
request=install_request
|
|
1081
|
+
)
|
|
1082
|
+
|
|
1083
|
+
# Uninstall assistant
|
|
1084
|
+
response = client.vendor_assistants.uninstall_assistant(
|
|
1085
|
+
vendor=VendorType.AWS,
|
|
1086
|
+
setting_id="setting-id",
|
|
1087
|
+
assistant_id="assistant-id"
|
|
1088
|
+
)
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
#### Vendor Workflow Service
|
|
1092
|
+
|
|
1093
|
+
Manage cloud vendor workflows (AWS Step Functions).
|
|
1094
|
+
|
|
1095
|
+
**Core Methods:**
|
|
1096
|
+
|
|
1097
|
+
1. **Get Workflow Settings**
|
|
1098
|
+
```python
|
|
1099
|
+
# Get workflow settings for a vendor
|
|
1100
|
+
settings = client.vendor_workflows.get_workflow_settings(
|
|
1101
|
+
vendor=VendorType.AWS,
|
|
1102
|
+
page=0,
|
|
1103
|
+
per_page=10
|
|
1104
|
+
)
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
2. **Get Workflows**
|
|
1108
|
+
```python
|
|
1109
|
+
# Get workflows for a specific setting
|
|
1110
|
+
workflows = client.vendor_workflows.get_workflows(
|
|
1111
|
+
vendor=VendorType.AWS,
|
|
1112
|
+
setting_id="setting-id",
|
|
1113
|
+
per_page=10,
|
|
1114
|
+
next_token=None
|
|
1115
|
+
)
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
3. **Get Workflow Details**
|
|
1119
|
+
```python
|
|
1120
|
+
# Get specific workflow
|
|
1121
|
+
workflow = client.vendor_workflows.get_workflow(
|
|
1122
|
+
vendor=VendorType.AWS,
|
|
1123
|
+
setting_id="setting-id",
|
|
1124
|
+
workflow_id="workflow-id"
|
|
1125
|
+
)
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
4. **Install/Uninstall Workflows**
|
|
1129
|
+
```python
|
|
1130
|
+
from codemie_sdk.models.vendor_workflow import VendorWorkflowInstallRequest
|
|
1131
|
+
|
|
1132
|
+
# Install workflow
|
|
1133
|
+
install_request = VendorWorkflowInstallRequest(
|
|
1134
|
+
workflow_id="workflow-id",
|
|
1135
|
+
project="project-name"
|
|
1136
|
+
)
|
|
1137
|
+
|
|
1138
|
+
response = client.vendor_workflows.install_workflow(
|
|
1139
|
+
vendor=VendorType.AWS,
|
|
1140
|
+
setting_id="setting-id",
|
|
1141
|
+
request=install_request
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
# Uninstall workflow
|
|
1145
|
+
response = client.vendor_workflows.uninstall_workflow(
|
|
1146
|
+
vendor=VendorType.AWS,
|
|
1147
|
+
setting_id="setting-id",
|
|
1148
|
+
workflow_id="workflow-id"
|
|
1149
|
+
)
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
#### Vendor Knowledge Base Service
|
|
1153
|
+
|
|
1154
|
+
Manage cloud vendor knowledge bases (AWS Bedrock Knowledge Bases).
|
|
1155
|
+
|
|
1156
|
+
**Core Methods:**
|
|
1157
|
+
|
|
1158
|
+
1. **Get Knowledge Base Settings**
|
|
1159
|
+
```python
|
|
1160
|
+
# Get knowledge base settings for a vendor
|
|
1161
|
+
settings = client.vendor_knowledgebases.get_knowledgebase_settings(
|
|
1162
|
+
vendor=VendorType.AWS,
|
|
1163
|
+
page=0,
|
|
1164
|
+
per_page=10
|
|
1165
|
+
)
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
2. **Get Knowledge Bases**
|
|
1169
|
+
```python
|
|
1170
|
+
# Get knowledge bases for a specific setting
|
|
1171
|
+
kbs = client.vendor_knowledgebases.get_knowledgebases(
|
|
1172
|
+
vendor=VendorType.AWS,
|
|
1173
|
+
setting_id="setting-id",
|
|
1174
|
+
per_page=10,
|
|
1175
|
+
next_token=None
|
|
1176
|
+
)
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
3. **Get Knowledge Base Details**
|
|
1180
|
+
```python
|
|
1181
|
+
# Get specific knowledge base with details
|
|
1182
|
+
kb_detail = client.vendor_knowledgebases.get_knowledgebase_detail(
|
|
1183
|
+
vendor=VendorType.AWS,
|
|
1184
|
+
setting_id="setting-id",
|
|
1185
|
+
kb_id="kb-id"
|
|
1186
|
+
)
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
4. **Install/Uninstall Knowledge Bases**
|
|
1190
|
+
```python
|
|
1191
|
+
from codemie_sdk.models.vendor_knowledgebase import VendorKnowledgeBaseInstallRequest
|
|
1192
|
+
|
|
1193
|
+
# Install knowledge base
|
|
1194
|
+
install_request = VendorKnowledgeBaseInstallRequest(
|
|
1195
|
+
kb_id="kb-id",
|
|
1196
|
+
project="project-name"
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
response = client.vendor_knowledgebases.install_knowledgebase(
|
|
1200
|
+
vendor=VendorType.AWS,
|
|
1201
|
+
setting_id="setting-id",
|
|
1202
|
+
request=install_request
|
|
1203
|
+
)
|
|
1204
|
+
|
|
1205
|
+
# Uninstall knowledge base
|
|
1206
|
+
response = client.vendor_knowledgebases.uninstall_knowledgebase(
|
|
1207
|
+
vendor=VendorType.AWS,
|
|
1208
|
+
setting_id="setting-id",
|
|
1209
|
+
kb_id="kb-id"
|
|
1210
|
+
)
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
#### Vendor Guardrail Service
|
|
1214
|
+
|
|
1215
|
+
Manage cloud vendor guardrails (AWS Bedrock Guardrails).
|
|
1216
|
+
|
|
1217
|
+
**Core Methods:**
|
|
1218
|
+
|
|
1219
|
+
1. **Get Guardrail Settings**
|
|
1220
|
+
```python
|
|
1221
|
+
# Get guardrail settings for a vendor
|
|
1222
|
+
settings = client.vendor_guardrails.get_guardrail_settings(
|
|
1223
|
+
vendor=VendorType.AWS,
|
|
1224
|
+
page=0,
|
|
1225
|
+
per_page=10
|
|
1226
|
+
)
|
|
1227
|
+
|
|
1228
|
+
# Check for invalid settings
|
|
1229
|
+
for setting in settings.data:
|
|
1230
|
+
if setting.invalid:
|
|
1231
|
+
print(f"Error: {setting.error}")
|
|
1232
|
+
```
|
|
1233
|
+
|
|
1234
|
+
2. **Get Guardrails**
|
|
1235
|
+
```python
|
|
1236
|
+
# Get guardrails for a specific setting
|
|
1237
|
+
guardrails = client.vendor_guardrails.get_guardrails(
|
|
1238
|
+
vendor=VendorType.AWS,
|
|
1239
|
+
setting_id="setting-id",
|
|
1240
|
+
per_page=10,
|
|
1241
|
+
next_token=None
|
|
1242
|
+
)
|
|
1243
|
+
```
|
|
1244
|
+
|
|
1245
|
+
3. **Get Guardrail Details and Versions**
|
|
1246
|
+
```python
|
|
1247
|
+
# Get specific guardrail
|
|
1248
|
+
guardrail = client.vendor_guardrails.get_guardrail(
|
|
1249
|
+
vendor=VendorType.AWS,
|
|
1250
|
+
setting_id="setting-id",
|
|
1251
|
+
guardrail_id="guardrail-id"
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
# Get guardrail versions
|
|
1255
|
+
versions = client.vendor_guardrails.get_guardrail_versions(
|
|
1256
|
+
vendor=VendorType.AWS,
|
|
1257
|
+
setting_id="setting-id",
|
|
1258
|
+
guardrail_id="guardrail-id"
|
|
1259
|
+
)
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
4. **Install/Uninstall Guardrails**
|
|
1263
|
+
```python
|
|
1264
|
+
from codemie_sdk.models.vendor_guardrail import VendorGuardrailInstallRequest
|
|
1265
|
+
|
|
1266
|
+
# Install guardrail
|
|
1267
|
+
install_request = VendorGuardrailInstallRequest(
|
|
1268
|
+
guardrail_id="guardrail-id",
|
|
1269
|
+
version="1.0",
|
|
1270
|
+
project="project-name"
|
|
1271
|
+
)
|
|
1272
|
+
|
|
1273
|
+
response = client.vendor_guardrails.install_guardrail(
|
|
1274
|
+
vendor=VendorType.AWS,
|
|
1275
|
+
setting_id="setting-id",
|
|
1276
|
+
request=install_request
|
|
1277
|
+
)
|
|
1278
|
+
|
|
1279
|
+
# Uninstall guardrail
|
|
1280
|
+
response = client.vendor_guardrails.uninstall_guardrail(
|
|
1281
|
+
vendor=VendorType.AWS,
|
|
1282
|
+
setting_id="setting-id",
|
|
1283
|
+
guardrail_id="guardrail-id"
|
|
1284
|
+
)
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
## Error Handling
|
|
1288
|
+
|
|
1289
|
+
The SDK implements comprehensive error handling. All API calls may raise exceptions for:
|
|
1290
|
+
- Authentication failures
|
|
1291
|
+
- Network errors
|
|
1292
|
+
- Invalid parameters
|
|
1293
|
+
- Server-side errors
|
|
1294
|
+
|
|
1295
|
+
It's recommended to implement try-catch blocks around SDK operations to handle potential exceptions gracefully.
|
|
1296
|
+
|
|
1297
|
+
## Authentication
|
|
1298
|
+
|
|
1299
|
+
The SDK supports two authentication methods through Keycloak:
|
|
1300
|
+
|
|
1301
|
+
1. Username/Password Authentication
|
|
1302
|
+
2. Client Credentials Authentication
|
|
1303
|
+
|
|
1304
|
+
### Required Parameters
|
|
1305
|
+
|
|
1306
|
+
You must provide either:
|
|
1307
|
+
|
|
1308
|
+
- Username/Password credentials:
|
|
1309
|
+
```python
|
|
1310
|
+
{
|
|
1311
|
+
"username": "your-username",
|
|
1312
|
+
"password": "your-password",
|
|
1313
|
+
"auth_client_id": "client-id", # Optional, defaults to "codemie-sdk"
|
|
1314
|
+
"auth_realm_name": "realm-name",
|
|
1315
|
+
"auth_server_url": "keycloak-url",
|
|
1316
|
+
"verify_ssl": True # Optional, defaults to True
|
|
1317
|
+
}
|
|
1318
|
+
```
|
|
1319
|
+
|
|
1320
|
+
OR
|
|
1321
|
+
|
|
1322
|
+
- Client Credentials:
|
|
1323
|
+
```python
|
|
1324
|
+
{
|
|
1325
|
+
"auth_client_id": "your-client-id",
|
|
1326
|
+
"auth_client_secret": "your-client-secret",
|
|
1327
|
+
"auth_realm_name": "realm-name",
|
|
1328
|
+
"auth_server_url": "keycloak-url",
|
|
1329
|
+
"verify_ssl": True # Optional, defaults to True
|
|
1330
|
+
}
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
### Usage Examples
|
|
1334
|
+
|
|
1335
|
+
1. Username/Password Authentication:
|
|
1336
|
+
```python
|
|
1337
|
+
from codemie_sdk import CodeMieClient
|
|
1338
|
+
|
|
1339
|
+
client = CodeMieClient(
|
|
1340
|
+
codemie_api_domain="https://api.domain.com",
|
|
1341
|
+
username="your-username",
|
|
1342
|
+
password="your-password",
|
|
1343
|
+
auth_client_id="your-client-id", # Optional
|
|
1344
|
+
auth_realm_name="your-realm",
|
|
1345
|
+
auth_server_url="https://keycloak.domain.com/auth",
|
|
1346
|
+
verify_ssl=True # Optional
|
|
1347
|
+
)
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
2. Client Credentials Authentication:
|
|
1351
|
+
```python
|
|
1352
|
+
from codemie_sdk.auth import KeycloakCredentials
|
|
1353
|
+
|
|
1354
|
+
credentials = KeycloakCredentials(
|
|
1355
|
+
server_url="https://keycloak.domain.com/auth",
|
|
1356
|
+
realm_name="your-realm",
|
|
1357
|
+
client_id="your-client-id",
|
|
1358
|
+
client_secret="your-client-secret",
|
|
1359
|
+
verify_ssl=True # Optional
|
|
1360
|
+
)
|
|
1361
|
+
|
|
1362
|
+
client = CodeMieClient(
|
|
1363
|
+
codemie_api_domain="https://api.domain.com",
|
|
1364
|
+
credentials=credentials
|
|
1365
|
+
)
|
|
1366
|
+
```
|
|
1367
|
+
|
|
1368
|
+
## Support
|
|
1369
|
+
|
|
1370
|
+
For providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com
|
|
1371
|
+
|
|
1372
|
+
## Development
|
|
1373
|
+
|
|
1374
|
+
### Setup
|
|
1375
|
+
|
|
1376
|
+
```bash
|
|
1377
|
+
# Install dependencies
|
|
1378
|
+
poetry install
|
|
1379
|
+
|
|
1380
|
+
# Or using make
|
|
1381
|
+
make install
|
|
1382
|
+
```
|
|
1383
|
+
|
|
1384
|
+
### Code Quality
|
|
1385
|
+
|
|
1386
|
+
```bash
|
|
1387
|
+
# Run linter (check and fix)
|
|
1388
|
+
make ruff
|
|
1389
|
+
|
|
1390
|
+
# Or manually
|
|
1391
|
+
poetry run ruff check --fix
|
|
1392
|
+
poetry run ruff format
|
|
1393
|
+
```
|
|
1394
|
+
|
|
1395
|
+
### Building Package
|
|
1396
|
+
|
|
1397
|
+
```bash
|
|
1398
|
+
# Build package
|
|
1399
|
+
poetry build
|
|
1400
|
+
# Or make build
|
|
1401
|
+
|
|
1402
|
+
# Publish to PyPI
|
|
1403
|
+
make publish
|
|
1404
|
+
```
|