codemie-sdk-python 0.1.229__tar.gz → 0.1.231__tar.gz

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.
Files changed (45) hide show
  1. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/PKG-INFO +48 -9
  2. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/README.md +47 -8
  3. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/pyproject.toml +1 -1
  4. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/__init__.py +1 -1
  5. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/assistant.py +8 -0
  6. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/workflow_execution_payload.py +4 -0
  7. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/assistant.py +40 -0
  8. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/workflow.py +10 -1
  9. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/workflow_execution.py +26 -4
  10. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/utils/http.py +13 -2
  11. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/auth/__init__.py +0 -0
  12. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/auth/credentials.py +0 -0
  13. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/client/__init__.py +0 -0
  14. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/client/client.py +0 -0
  15. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/exceptions.py +0 -0
  16. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/__init__.py +0 -0
  17. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/common.py +0 -0
  18. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/conversation.py +0 -0
  19. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/datasource.py +0 -0
  20. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/file_operation.py +0 -0
  21. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/integration.py +0 -0
  22. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/llm.py +0 -0
  23. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/task.py +0 -0
  24. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/user.py +0 -0
  25. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/vendor_assistant.py +0 -0
  26. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/vendor_guardrail.py +0 -0
  27. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/vendor_knowledgebase.py +0 -0
  28. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/vendor_workflow.py +0 -0
  29. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/workflow.py +0 -0
  30. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/workflow_state.py +0 -0
  31. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/models/workflow_thoughts.py +0 -0
  32. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/conversation.py +0 -0
  33. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/datasource.py +0 -0
  34. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/files.py +0 -0
  35. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/integration.py +0 -0
  36. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/llm.py +0 -0
  37. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/task.py +0 -0
  38. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/user.py +0 -0
  39. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/vendor_assistant.py +0 -0
  40. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/vendor_guardrail.py +0 -0
  41. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/vendor_knowledgebase.py +0 -0
  42. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/vendor_workflow.py +0 -0
  43. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/webhook.py +0 -0
  44. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/services/workflow_execution_state.py +0 -0
  45. {codemie_sdk_python-0.1.229 → codemie_sdk_python-0.1.231}/src/codemie_sdk/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codemie-sdk-python
3
- Version: 0.1.229
3
+ Version: 0.1.231
4
4
  Summary: CodeMie SDK for Python
5
5
  Author: Vadym Vlasenko
6
6
  Author-email: vadym_vlasenko@epam.com
@@ -174,16 +174,41 @@ result = client.assistant.delete("assistant-id")
174
174
 
175
175
  #### Advanced Features
176
176
 
177
- 6. **Chat with Assistant**
177
+ 6. **Chat with Assistant (with MCP header propagation)**
178
178
  ```python
179
179
  from codemie_sdk.models.assistant import AssistantChatRequest
180
180
 
181
181
  chat_request = AssistantChatRequest(
182
182
  text="Your message here",
183
183
  stream=False, # Set to True for streaming response
184
- # Additional parameters
184
+ propagate_headers=True, # Enable propagation of X-* headers to MCP servers
185
+ )
186
+ # Pass X-* headers to forward to MCP servers
187
+ response = client.assistant.chat(
188
+ "assistant-id",
189
+ chat_request,
190
+ headers={
191
+ "X-Tenant-ID": "tenant-abc-123",
192
+ "X-User-ID": "user-456",
193
+ "X-Request-ID": "req-123",
194
+ },
195
+ )
196
+ ```
197
+
198
+ 6.a. **Chat with Assistant by slug (with MCP header propagation)**
199
+ ```python
200
+ chat_request = AssistantChatRequest(
201
+ text="Your message here",
202
+ propagate_headers=True,
203
+ )
204
+ response = client.assistants.chat_by_slug(
205
+ "assistant-slug",
206
+ chat_request,
207
+ headers={
208
+ "X-Environment": "production",
209
+ "X-Feature-Flag-Beta": "true",
210
+ },
185
211
  )
186
- response = client.assistant.chat("assistant-id", chat_request)
187
212
  ```
188
213
 
189
214
  7. **Utilize structured outputs with Assistant**
@@ -548,10 +573,18 @@ result = client.workflow.delete("workflow-id")
548
573
 
549
574
  The SDK provides comprehensive workflow execution management through the WorkflowExecutionService:
550
575
 
551
- 1. **Run Workflow**
576
+ 1. **Run Workflow (with MCP header propagation)**
552
577
  ```python
553
- # Simple workflow execution
554
- execution = client.workflow.run("workflow-id", user_input="optional input")
578
+ # Enable propagation in payload and pass X-* headers to forward to MCP servers
579
+ execution = client.workflow.run(
580
+ "workflow-id",
581
+ user_input="optional input",
582
+ propagate_headers=True,
583
+ headers={
584
+ "X-Request-ID": "req-abc-123",
585
+ "X-Source-App": "analytics-ui",
586
+ },
587
+ )
555
588
 
556
589
  # Get execution service for advanced operations
557
590
  execution_service = client.workflow.executions("workflow-id")
@@ -571,8 +604,14 @@ execution = execution_service.get("execution-id")
571
604
  # Abort running execution
572
605
  result = execution_service.abort("execution-id")
573
606
 
574
- # Resume interrupted execution
575
- result = execution_service.resume("execution-id")
607
+ # Resume interrupted execution with header propagation (query param + headers)
608
+ result = execution_service.resume(
609
+ "execution-id",
610
+ propagate_headers=True,
611
+ headers={
612
+ "X-Correlation-ID": "corr-456",
613
+ },
614
+ )
576
615
 
577
616
  # Delete all executions
578
617
  result = execution_service.delete_all()
@@ -161,16 +161,41 @@ result = client.assistant.delete("assistant-id")
161
161
 
162
162
  #### Advanced Features
163
163
 
164
- 6. **Chat with Assistant**
164
+ 6. **Chat with Assistant (with MCP header propagation)**
165
165
  ```python
166
166
  from codemie_sdk.models.assistant import AssistantChatRequest
167
167
 
168
168
  chat_request = AssistantChatRequest(
169
169
  text="Your message here",
170
170
  stream=False, # Set to True for streaming response
171
- # Additional parameters
171
+ propagate_headers=True, # Enable propagation of X-* headers to MCP servers
172
+ )
173
+ # Pass X-* headers to forward to MCP servers
174
+ response = client.assistant.chat(
175
+ "assistant-id",
176
+ chat_request,
177
+ headers={
178
+ "X-Tenant-ID": "tenant-abc-123",
179
+ "X-User-ID": "user-456",
180
+ "X-Request-ID": "req-123",
181
+ },
182
+ )
183
+ ```
184
+
185
+ 6.a. **Chat with Assistant by slug (with MCP header propagation)**
186
+ ```python
187
+ chat_request = AssistantChatRequest(
188
+ text="Your message here",
189
+ propagate_headers=True,
190
+ )
191
+ response = client.assistants.chat_by_slug(
192
+ "assistant-slug",
193
+ chat_request,
194
+ headers={
195
+ "X-Environment": "production",
196
+ "X-Feature-Flag-Beta": "true",
197
+ },
172
198
  )
173
- response = client.assistant.chat("assistant-id", chat_request)
174
199
  ```
175
200
 
176
201
  7. **Utilize structured outputs with Assistant**
@@ -535,10 +560,18 @@ result = client.workflow.delete("workflow-id")
535
560
 
536
561
  The SDK provides comprehensive workflow execution management through the WorkflowExecutionService:
537
562
 
538
- 1. **Run Workflow**
563
+ 1. **Run Workflow (with MCP header propagation)**
539
564
  ```python
540
- # Simple workflow execution
541
- execution = client.workflow.run("workflow-id", user_input="optional input")
565
+ # Enable propagation in payload and pass X-* headers to forward to MCP servers
566
+ execution = client.workflow.run(
567
+ "workflow-id",
568
+ user_input="optional input",
569
+ propagate_headers=True,
570
+ headers={
571
+ "X-Request-ID": "req-abc-123",
572
+ "X-Source-App": "analytics-ui",
573
+ },
574
+ )
542
575
 
543
576
  # Get execution service for advanced operations
544
577
  execution_service = client.workflow.executions("workflow-id")
@@ -558,8 +591,14 @@ execution = execution_service.get("execution-id")
558
591
  # Abort running execution
559
592
  result = execution_service.abort("execution-id")
560
593
 
561
- # Resume interrupted execution
562
- result = execution_service.resume("execution-id")
594
+ # Resume interrupted execution with header propagation (query param + headers)
595
+ result = execution_service.resume(
596
+ "execution-id",
597
+ propagate_headers=True,
598
+ headers={
599
+ "X-Correlation-ID": "corr-456",
600
+ },
601
+ )
563
602
 
564
603
  # Delete all executions
565
604
  result = execution_service.delete_all()
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codemie-sdk-python"
3
- version = "0.1.229"
3
+ version = "0.1.231"
4
4
  description = "CodeMie SDK for Python"
5
5
  authors = [
6
6
  "Vadym Vlasenko <vadym_vlasenko@epam.com>",
@@ -78,7 +78,7 @@ from .services.vendor_workflow import VendorWorkflowService
78
78
  from .services.vendor_knowledgebase import VendorKnowledgeBaseService
79
79
  from .services.vendor_guardrail import VendorGuardrailService
80
80
 
81
- __version__ = "0.2.11"
81
+ __version__ = "0.2.12"
82
82
  __all__ = [
83
83
  "CodeMieClient",
84
84
  "VendorType",
@@ -284,6 +284,14 @@ class AssistantChatRequest(BaseModel):
284
284
  default=None, description="DataSource in conversation history"
285
285
  )
286
286
  stream: bool = Field(default=False, description="Enable streaming response")
287
+ propagate_headers: bool = Field(
288
+ default=False,
289
+ description="Enable propagation of X-* HTTP headers to MCP servers during tool execution",
290
+ )
291
+ custom_metadata: Optional[dict[str, Any]] = Field(
292
+ default=None,
293
+ description="Custom metadata for the AI Assistant",
294
+ )
287
295
  top_k: int = Field(default=10, description="Top K results to consider")
288
296
  system_prompt: str = Field(default="", description="Override system prompt")
289
297
  background_task: bool = Field(default=False, description="Run as background task")
@@ -15,3 +15,7 @@ class WorkflowExecutionCreateRequest(BaseModel):
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
+ )
@@ -309,12 +309,14 @@ class AssistantService:
309
309
  self,
310
310
  assistant_id: str,
311
311
  request: AssistantChatRequest,
312
+ headers: Optional[Dict[str, str]] = None,
312
313
  ) -> Union[requests.Response, BaseModelResponse]:
313
314
  """Send a chat request to an assistant.
314
315
 
315
316
  Args:
316
317
  assistant_id: ID of the assistant to chat with
317
318
  request: Chat request details
319
+ headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
318
320
 
319
321
  Returns:
320
322
  Chat response or streaming response
@@ -333,6 +335,7 @@ class AssistantService:
333
335
  BaseModelResponse,
334
336
  json_data=request.model_dump(exclude_none=True, by_alias=True),
335
337
  stream=request.stream,
338
+ extra_headers=headers,
336
339
  )
337
340
  if not request.stream and pydantic_schema:
338
341
  # we do conversion to the BaseModel here because self._parse_response don't see actual request model,
@@ -380,6 +383,43 @@ class AssistantService:
380
383
 
381
384
  return response
382
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
+
383
423
  def upload_file_to_chat(self, file_path: Path):
384
424
  """Upload a file to assistant chat and return the response containing file_url."""
385
425
 
@@ -135,6 +135,8 @@ class WorkflowService:
135
135
  workflow_id: str,
136
136
  user_input: Optional[str] = None,
137
137
  file_name: Optional[str] = None,
138
+ propagate_headers: bool = False,
139
+ headers: Optional[dict[str, str]] = None,
138
140
  ) -> dict:
139
141
  """Run a workflow with optional input parameters.
140
142
 
@@ -142,11 +144,18 @@ class WorkflowService:
142
144
  workflow_id: ID of the workflow to run
143
145
  user_input: Optional user input for the workflow execution
144
146
  file_name: Optional file name for the workflow execution
147
+ propagate_headers: Enable propagation of X-* HTTP headers to MCP servers
148
+ headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
145
149
 
146
150
  Returns:
147
151
  dict: Created workflow execution details
148
152
  """
149
- return self.executions(workflow_id).create(user_input, file_name)
153
+ return self.executions(workflow_id).create(
154
+ user_input=user_input,
155
+ file_name=file_name,
156
+ propagate_headers=propagate_headers,
157
+ headers=headers,
158
+ )
150
159
 
151
160
  def executions(self, workflow_id: str) -> WorkflowExecutionService:
152
161
  """Get workflow execution service for the specified workflow.
@@ -46,24 +46,33 @@ class WorkflowExecutionService:
46
46
  )
47
47
 
48
48
  def create(
49
- self, user_input: Optional[str] = None, file_name: Optional[str] = None
49
+ self,
50
+ user_input: Optional[str] = None,
51
+ file_name: Optional[str] = None,
52
+ propagate_headers: bool = False,
53
+ headers: Optional[dict[str, str]] = None,
50
54
  ) -> dict:
51
55
  """Create a new workflow execution.
52
56
 
53
57
  Args:
54
58
  user_input: Optional input data for the workflow execution.
55
59
  file_name: Optional file name associated with the workflow execution.
60
+ propagate_headers: Enable propagation of X-* HTTP headers to MCP servers.
61
+ headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
56
62
 
57
63
  Returns:
58
64
  dict: Created workflow execution details
59
65
  """
60
66
  payload = WorkflowExecutionCreateRequest(
61
- user_input=user_input, file_name=file_name
67
+ user_input=user_input,
68
+ file_name=file_name,
69
+ propagate_headers=propagate_headers,
62
70
  )
63
71
  return self._api.post(
64
72
  f"/v1/workflows/{self._workflow_id}/executions",
65
73
  dict,
66
74
  json_data=payload.model_dump(),
75
+ extra_headers=headers,
67
76
  )
68
77
 
69
78
  def get(self, execution_id: str) -> WorkflowExecution:
@@ -108,17 +117,30 @@ class WorkflowExecutionService:
108
117
  f"/v1/workflows/{self._workflow_id}/executions/{execution_id}/abort", dict
109
118
  )
110
119
 
111
- def resume(self, execution_id: str) -> dict:
120
+ def resume(
121
+ self,
122
+ execution_id: str,
123
+ propagate_headers: bool = False,
124
+ headers: Optional[dict[str, str]] = None,
125
+ ) -> dict:
112
126
  """Resume an interrupted workflow execution.
113
127
 
114
128
  Args:
115
129
  execution_id: ID of the execution to resume
130
+ propagate_headers: Enable propagation of X-* HTTP headers to MCP servers.
131
+ headers: Optional additional HTTP headers (e.g., X-* for MCP propagation)
116
132
 
117
133
  Returns:
118
134
  dict: Updated workflow execution details
119
135
  """
136
+ params = {"propagate_headers": propagate_headers}
137
+ # Empty body per API; passing empty dict to satisfy typing
120
138
  return self._api.put(
121
- f"/v1/workflows/{self._workflow_id}/executions/{execution_id}/resume", dict
139
+ f"/v1/workflows/{self._workflow_id}/executions/{execution_id}/resume",
140
+ dict,
141
+ json_data={},
142
+ params=params,
143
+ extra_headers=headers,
122
144
  )
123
145
 
124
146
  def get_thoughts(
@@ -161,6 +161,7 @@ class ApiRequestHandler:
161
161
  stream: bool = False,
162
162
  wrap_response: bool = True,
163
163
  raise_on_error: bool = True,
164
+ extra_headers: Optional[Dict[str, str]] = None,
164
165
  ) -> Union[T, requests.Response]:
165
166
  """Makes a POST request and parses the response.
166
167
 
@@ -171,6 +172,7 @@ class ApiRequestHandler:
171
172
  stream: Whether to return streaming response
172
173
  wrap_response: Whether response is wrapped in 'data' field
173
174
  raise_on_error: Whether to raise exception on HTTP error status codes
175
+ extra_headers: Optional additional HTTP headers to include (e.g., X-* for MCP propagation)
174
176
 
175
177
  Returns:
176
178
  Parsed response object/list or streaming response
@@ -178,9 +180,13 @@ class ApiRequestHandler:
178
180
  if json_data:
179
181
  logger.debug(f"Request body: {json_data}")
180
182
 
183
+ headers = self._get_headers()
184
+ if extra_headers:
185
+ headers.update(extra_headers)
186
+
181
187
  response = requests.post(
182
188
  url=f"{self._base_url}{endpoint}",
183
- headers=self._get_headers(),
189
+ headers=headers,
184
190
  json=json_data,
185
191
  verify=self._verify_ssl,
186
192
  stream=stream,
@@ -242,6 +248,7 @@ class ApiRequestHandler:
242
248
  json_data: Dict[str, Any],
243
249
  params: Optional[Dict[str, Any]] = None,
244
250
  wrap_response: bool = True,
251
+ extra_headers: Optional[Dict[str, str]] = None,
245
252
  ) -> T:
246
253
  """Makes a PUT request and parses the response.
247
254
 
@@ -251,14 +258,18 @@ class ApiRequestHandler:
251
258
  json_data: JSON request body
252
259
  params: Query parameters
253
260
  wrap_response: Whether response is wrapped in 'data' field
261
+ extra_headers: Optional additional HTTP headers to include (e.g., X-* for MCP propagation)
254
262
 
255
263
  Returns:
256
264
  Parsed response object or list of objects
257
265
  """
258
266
  logger.debug(f"Request body: {json_data}")
267
+ headers = self._get_headers()
268
+ if extra_headers:
269
+ headers.update(extra_headers)
259
270
  response = requests.put(
260
271
  url=f"{self._base_url}{endpoint}",
261
- headers=self._get_headers(),
272
+ headers=headers,
262
273
  json=json_data,
263
274
  params=params,
264
275
  verify=self._verify_ssl,