codemie-sdk-python 0.1.5__py3-none-any.whl → 0.1.6__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.

@@ -51,6 +51,11 @@ class CodeMieClient:
51
51
  self._token: Optional[str] = None
52
52
  self._api_domain = codemie_api_domain.rstrip("/")
53
53
  self._verify_ssl = verify_ssl
54
+ if not verify_ssl:
55
+ import requests
56
+ from urllib3.exceptions import InsecureRequestWarning
57
+
58
+ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
54
59
 
55
60
  # Initialize token first
56
61
  self._token = self.auth.get_token()
@@ -11,6 +11,28 @@ from .common import User
11
11
  from .integration import Integration
12
12
 
13
13
 
14
+ class GitToolName(str, Enum):
15
+ """Enum for Git tool names."""
16
+
17
+ LIST_BRANCHES_IN_REPO = "list_branches_in_repo"
18
+ CREATE_BRANCH = "create_branch"
19
+ SET_ACTIVE_BRANCH = "set_active_branch"
20
+ CREATE_FILE = "create_file"
21
+ UPDATE_FILE = "update_file"
22
+ UPDATE_FILE_DIFF = "update_file_diff"
23
+ DELETE_FILE = "delete_file"
24
+ CREATE_PULL_REQUEST = "create_pull_request"
25
+ GET_PR_CHANGES = "get_pr_changes"
26
+ CREATE_PR_CHANGES_COMMENT = "create_pr_changes_comment"
27
+
28
+
29
+ class VcsToolName(str, Enum):
30
+ """Enum for VCS tool names."""
31
+
32
+ GITLAB = "gitlab"
33
+ GITHUB = "github"
34
+
35
+
14
36
  class ToolDetails(BaseModel):
15
37
  """Model for tool details."""
16
38
 
@@ -23,6 +45,13 @@ class ToolDetails(BaseModel):
23
45
  settings: Optional[Integration] = None
24
46
 
25
47
 
48
+ class Toolkit(str, Enum):
49
+ """Enum for toolkits."""
50
+
51
+ GIT = "Git"
52
+ VCS = "VCS"
53
+
54
+
26
55
  class ToolKitDetails(BaseModel):
27
56
  """Model for toolkit details."""
28
57
 
@@ -149,7 +178,7 @@ class AssistantChatRequest(BaseModel):
149
178
  conversation_id: Optional[str] = Field(
150
179
  default=str(uuid.uuid4()), description="Conversation identifier"
151
180
  )
152
- text: Optional[str] = Field(default=None, description="User's input error_message")
181
+ text: str = Field(description="User's input")
153
182
  content_raw: Optional[str] = Field(default="", description="Raw content input")
154
183
  file_name: Optional[str] = Field(default=None, description="Associated file name")
155
184
  llm_model: Optional[str] = Field(
@@ -166,6 +195,9 @@ class AssistantChatRequest(BaseModel):
166
195
  top_k: int = Field(default=10, description="Top K results to consider")
167
196
  system_prompt: str = Field(default="", description="Override system prompt")
168
197
  background_task: bool = Field(default=False, description="Run as background task")
198
+ metadata: Optional[dict[str, Any]] = Field(
199
+ default=None, description="Provide additional metadata"
200
+ )
169
201
 
170
202
 
171
203
  class BaseModelResponse(BaseModel):
@@ -1,7 +1,7 @@
1
1
  import re
2
2
  from datetime import datetime
3
3
  from enum import Enum
4
- from typing import Optional, List
4
+ from typing import Optional, List, Union
5
5
 
6
6
  from pydantic import BaseModel, Field, model_validator, ConfigDict, field_validator
7
7
 
@@ -20,6 +20,10 @@ class DataSourceType(str, Enum):
20
20
  JIRA = "knowledge_base_jira"
21
21
  FILE = "knowledge_base_file"
22
22
  GOOGLE = "llm_routing_google"
23
+ PROVIDER = "provider"
24
+ SUMMARY = "summary"
25
+ CHUNK_SUMMARY = "chunk-summary"
26
+ JSON = "knowledge_base_json"
23
27
 
24
28
 
25
29
  class DataSourceStatus(str, Enum):
@@ -37,7 +41,7 @@ class DataSourceProcessingInfo(BaseModel):
37
41
  total_size_kb: Optional[float] = None
38
42
  average_file_size_bytes: Optional[float] = None
39
43
  unique_extensions: Optional[List[str]] = None
40
- filtered_documents: Optional[int] = None
44
+ filtered_documents: Optional[Union[int, list]] = None
41
45
  processed_documents_count: Optional[int] = Field(None, alias="documents_count_key")
42
46
 
43
47
 
@@ -1,10 +1,10 @@
1
1
  """Models for assistant-related data structures."""
2
2
 
3
- from datetime import datetime
4
3
  from enum import Enum
5
4
  from typing import List, Optional, Any
5
+ from datetime import datetime
6
6
 
7
- from pydantic import BaseModel, Field, ConfigDict
7
+ from pydantic import BaseModel, Field, ConfigDict, field_serializer
8
8
 
9
9
 
10
10
  class CredentialTypes(str, Enum):
@@ -33,6 +33,8 @@ class CredentialTypes(str, Enum):
33
33
  ZEPHYR_SQUAD = "ZephyrSquad"
34
34
  SERVICE_NOW = "ServiceNow"
35
35
  DIAL = "DIAL"
36
+ A2A = "A2A"
37
+ MCP = "MCP"
36
38
 
37
39
 
38
40
  class IntegrationType(str, Enum):
@@ -66,3 +68,7 @@ class Integration(BaseModel):
66
68
  credential_type: CredentialTypes
67
69
  credential_values: List[CredentialValues]
68
70
  setting_type: IntegrationType = Field(default=IntegrationType.USER)
71
+
72
+ @field_serializer("date", "update_date")
73
+ def serialize_dt(self, dt: datetime, _info):
74
+ return dt.isoformat()
@@ -0,0 +1,51 @@
1
+ """Workflow execution state models."""
2
+
3
+ from datetime import datetime
4
+ from enum import Enum
5
+ from typing import Optional
6
+
7
+ from pydantic import BaseModel, ConfigDict
8
+
9
+
10
+ class WorkflowExecutionStatusEnum(str, Enum):
11
+ """Workflow execution state status."""
12
+
13
+ IN_PROGRESS = "In Progress"
14
+ NOT_STARTED = "Not Started"
15
+ INTERRUPTED = "Interrupted"
16
+ FAILED = "Failed"
17
+ SUCCEEDED = "Succeeded"
18
+ ABORTED = "Aborted"
19
+
20
+
21
+ class WorkflowExecutionStateThought(BaseModel):
22
+ """Model for workflow execution state thought."""
23
+
24
+ model_config = ConfigDict(populate_by_name=True)
25
+
26
+ id: str
27
+ text: str
28
+ created_at: datetime
29
+ parent_id: Optional[str] = None
30
+
31
+
32
+ class WorkflowExecutionState(BaseModel):
33
+ """Model for workflow execution state."""
34
+
35
+ model_config = ConfigDict(populate_by_name=True)
36
+
37
+ id: str
38
+ execution_id: str
39
+ name: str
40
+ task: Optional[str] = ""
41
+ status: WorkflowExecutionStatusEnum = WorkflowExecutionStatusEnum.NOT_STARTED
42
+ started_at: Optional[datetime] = None
43
+ completed_at: Optional[datetime] = None
44
+
45
+
46
+ class WorkflowExecutionStateOutput(BaseModel):
47
+ """Model for workflow execution state output."""
48
+
49
+ model_config = ConfigDict(populate_by_name=True)
50
+
51
+ output: Optional[str] = None
@@ -4,6 +4,7 @@ from typing import List, Optional
4
4
 
5
5
  from ..models.common import PaginationParams
6
6
  from ..models.workflow import WorkflowExecution
7
+ from .workflow_execution_state import WorkflowExecutionStateService
7
8
  from ..utils import ApiRequestHandler
8
9
 
9
10
 
@@ -71,6 +72,17 @@ class WorkflowExecutionService:
71
72
  WorkflowExecution,
72
73
  )
73
74
 
75
+ def states(self, execution_id: str) -> WorkflowExecutionStateService:
76
+ """Get states service for a specific workflow execution.
77
+
78
+ Args:
79
+ execution_id: ID of the execution to get states for
80
+
81
+ Returns:
82
+ WorkflowExecutionStateService: Service for managing states of this execution
83
+ """
84
+ return WorkflowExecutionStateService(self._api, self._workflow_id, execution_id)
85
+
74
86
  def delete_all(self) -> dict:
75
87
  """Delete all workflow executions."""
76
88
  return self._api.delete(f"/v1/workflows/{self._workflow_id}/executions", dict)
@@ -0,0 +1,61 @@
1
+ """Workflow execution state service implementation."""
2
+
3
+ from typing import List
4
+
5
+ from ..models.common import PaginationParams
6
+ from ..models.workflow_state import (
7
+ WorkflowExecutionState,
8
+ WorkflowExecutionStateOutput,
9
+ )
10
+ from ..utils import ApiRequestHandler
11
+
12
+
13
+ class WorkflowExecutionStateService:
14
+ """Service for managing workflow execution states."""
15
+
16
+ def __init__(self, api: ApiRequestHandler, workflow_id: str, execution_id: str):
17
+ """Initialize the workflow execution state service.
18
+
19
+ Args:
20
+ api: Request handler for API
21
+ workflow_id: ID of the workflow this service manages states for
22
+ execution_id: ID of the execution this service manages states for
23
+ """
24
+ self._api = api
25
+ self._workflow_id = workflow_id
26
+ self._execution_id = execution_id
27
+
28
+ def list(
29
+ self,
30
+ page: int = 0,
31
+ per_page: int = 10,
32
+ ) -> List[WorkflowExecutionState]:
33
+ """List states for the workflow execution with filtering and pagination support.
34
+
35
+ Args:
36
+ page: Page number (0-based). Must be >= 0. Defaults to 0.
37
+ per_page: Number of items per page. Must be > 0. Defaults to 10.
38
+
39
+ Returns:
40
+ List of WorkflowExecutionState containing state information.
41
+ """
42
+ params = PaginationParams(page=page, per_page=per_page).to_dict()
43
+ return self._api.get(
44
+ f"/v1/workflows/{self._workflow_id}/executions/{self._execution_id}/states",
45
+ List[WorkflowExecutionState],
46
+ params=params,
47
+ )
48
+
49
+ def get_output(self, state_id: str) -> WorkflowExecutionStateOutput:
50
+ """Get output for a specific execution state.
51
+
52
+ Args:
53
+ state_id: ID of the state to get output for
54
+
55
+ Returns:
56
+ WorkflowExecutionStateOutput containing the state output.
57
+ """
58
+ return self._api.get(
59
+ f"/v1/workflows/{self._workflow_id}/executions/{self._execution_id}/states/{state_id}/output",
60
+ WorkflowExecutionStateOutput,
61
+ )
codemie_sdk/utils/http.py CHANGED
@@ -48,10 +48,16 @@ class ApiRequestHandler:
48
48
 
49
49
  def _get_headers(self) -> dict:
50
50
  """Gets request headers with auth token."""
51
- return {
52
- "Authorization": f"Bearer {self._token}",
53
- "Content-Type": "application/json",
54
- }
51
+ headers = {"Content-Type": "application/json"}
52
+ if (
53
+ "0.0.0.0" in self._base_url
54
+ or "127.0.0.1" in self._base_url
55
+ or "localhost" in self._base_url
56
+ ):
57
+ headers["User-Id"] = "dev-codemie-user"
58
+ else:
59
+ headers["Authorization"] = f"Bearer {self._token}"
60
+ return headers
55
61
 
56
62
  def _parse_response(
57
63
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codemie-sdk-python
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: CodeMie SDK for Python
5
5
  Author: Vadym Vlasenko
6
6
  Author-email: vadym_vlasenko@epam.com
@@ -169,7 +169,7 @@ result = client.assistant.delete("assistant-id")
169
169
  from codemie_sdk.models.assistant import AssistantChatRequest
170
170
 
171
171
  chat_request = AssistantChatRequest(
172
- message="Your message here",
172
+ text="Your message here",
173
173
  stream=False, # Set to True for streaming response
174
174
  # Additional parameters
175
175
  )
@@ -525,6 +525,37 @@ result = execution_service.resume("execution-id")
525
525
  result = execution_service.delete_all()
526
526
  ```
527
527
 
528
+ 3. **Work with Execution States**
529
+ ```python
530
+ # Get execution states
531
+ states = execution_service.states(execution_id).list()
532
+
533
+ # Get state output
534
+ state_output = execution_service.states(execution_id).get_output(state_id)
535
+
536
+ # Example of monitoring workflow with state verification
537
+ def verify_workflow_execution(execution_service, execution_id):
538
+ execution = execution_service.get(execution_id)
539
+
540
+ if execution.status == ExecutionStatus.SUCCEEDED:
541
+ # Get and verify states
542
+ states = execution_service.states(execution_id).list()
543
+
544
+ # States are ordered by completion date
545
+ if len(states) >= 2:
546
+ first_state = states[0]
547
+ second_state = states[1]
548
+ assert first_state.completed_at < second_state.completed_at
549
+
550
+ # Get state outputs
551
+ for state in states:
552
+ output = execution_service.states(execution_id).get_output(state.id)
553
+ print(f"State {state.id} output: {output.output}")
554
+
555
+ elif execution.status == ExecutionStatus.FAILED:
556
+ print(f"Workflow failed: {execution.error_message}")
557
+ ```
558
+
528
559
  #### Workflow Configuration
529
560
 
530
561
  Workflows support various configuration options:
@@ -707,3 +738,65 @@ client = CodeMieClient(
707
738
  ## Support
708
739
  For providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com
709
740
 
741
+ ## Running tests
742
+
743
+ For running tests on custom environment you should create .env file in the root directory
744
+
745
+ ``` properties
746
+
747
+ AUTH_SERVER_URL=https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth
748
+ AUTH_CLIENT_ID=codemie-preview
749
+ AUTH_CLIENT_SECRET=<your_secret>
750
+ AUTH_REALM_NAME=codemie-prod
751
+ CODEMIE_API_DOMAIN=https://codemie-preview.lab.epam.com/code-assistant-api
752
+ VERIFY_SSL=False
753
+
754
+ USERNAME=<username>
755
+ PASSWORD=<password>
756
+
757
+ PROJECT_NAME=automation-tests-project
758
+
759
+ DEFAULT_TIMEOUT=60
760
+
761
+ GITLAB_URL=https://gitbud.epam.com
762
+ GITLAB_TOKEN=<gitlab_token>
763
+ GITLAB_PROJECT=https://gitbud.epam.com/epm-cdme/autotests/codemie-test-project
764
+ GITLAB_PROJECT_ID=<project_id>
765
+
766
+ GITHUB_URL=https://github.com
767
+ GITHUB_TOKEN=<github_token>
768
+ GITHUB_PROJECT=https://github.com/wild47/final_task
769
+
770
+ JIRA_URL=https://jiraeu.epam.com
771
+ JIRA_TOKEN=<jira_token>
772
+ JQL="project = 'EPMCDME' and issuetype = 'Epic' and status = 'Closed'"
773
+
774
+ CONFLUENCE_URL=https://kb.epam.com
775
+ CONFLUENCE_TOKEN=<konfluence_token>
776
+ CQL="space = EPMCDME and type = page and title = 'AQA Backlog Estimation'"
777
+ ```
778
+
779
+ Run all tests
780
+
781
+ ```shell
782
+ pytest -n auto --reruns 1
783
+ ```
784
+
785
+ Run e2e tests
786
+
787
+ ```shell
788
+ pytest -n auto -m e2e --reruns 1
789
+ ```
790
+
791
+ Run tests for e2e tests for specific integration/tool.
792
+ Available marks:
793
+ - jira_kb
794
+ - confluence_kb
795
+ - code_kb
796
+ - gitlab
797
+ - github
798
+ - git
799
+
800
+ ```shell
801
+ pytest -n auto -m "jira_kb or github" --reruns 1
802
+ ```
@@ -2,16 +2,17 @@ codemie_sdk/__init__.py,sha256=xfhrTFdvRmLSsrdQksX5GhnoQEj6tvkeytkrbB20Jj8,567
2
2
  codemie_sdk/auth/__init__.py,sha256=IksEj223xEZtJ-cQ0AT9L0Bs9psIJ8QNzDXrPTUQ3xQ,126
3
3
  codemie_sdk/auth/credentials.py,sha256=u2eLNsD8fELTgreQghVb0g0kk82zchUkux0M5lzq-u8,4320
4
4
  codemie_sdk/client/__init__.py,sha256=yf6C39MmrJ6gK9ZHMhBeynKwUUYVSUTQbKxU8-4qpKg,101
5
- codemie_sdk/client/client.py,sha256=aU4yr_Un4gX7SLXZ7rQiO_ObxE2__RyR8OdlxeKLRvc,4172
5
+ codemie_sdk/client/client.py,sha256=dVcWqd-ruWd8GOZ3_33C3LnHgUyyxIoCKxKYPYbBPq8,4373
6
6
  codemie_sdk/exceptions.py,sha256=XoVPyognx-JmyVxLHkZPAcX1CMi1OoT1diBFJLU54so,1183
7
- codemie_sdk/models/assistant.py,sha256=hx3R1H7UPqRvmBFKL7PDwHdVcX_CbjUsju55tjVRVEo,5538
7
+ codemie_sdk/models/assistant.py,sha256=5VT5DOUPsEjVTLEPQoxFw5yna0BDoJBq0D8daVIp7l4,6304
8
8
  codemie_sdk/models/common.py,sha256=V4sJCzwFTF8BPlrd2OKI44Em5HmPmn2Nm8fQNsnBZ_Q,1128
9
- codemie_sdk/models/datasource.py,sha256=Kjde8pXi4pm6x37g-c838C3yDg4tnTJHNvITA3rvmUk,9898
10
- codemie_sdk/models/integration.py,sha256=lhY_5Dxm0MDxp9vxL0H0HaM-ytNNoyBSOoEYTw4a-rU,1589
9
+ codemie_sdk/models/datasource.py,sha256=Iun6O76o4m-_jbyyumMndpyr4OiN0lwqKb8u5AOTHdM,10037
10
+ codemie_sdk/models/integration.py,sha256=F1YBdCK1w5W_jKK8prEsg7A00NghkEBvJgkkr8KpC6w,1764
11
11
  codemie_sdk/models/llm.py,sha256=ppb9-1dx1UFhRuJpSR3ij7H6Pfhe9nO4C4BEOIbToy4,1192
12
12
  codemie_sdk/models/task.py,sha256=J4ZFRY3s8qBGrqB5NLQF0rMbInLh4s7OEZ0ZfmnW0Ho,1476
13
13
  codemie_sdk/models/user.py,sha256=Q0rjimZh-IbeaPfq6b6fk6ZaCtwLqWHEIlU863suCS4,1777
14
14
  codemie_sdk/models/workflow.py,sha256=CyK-kBnOck2KiRX3gmWF_mcGtqxsGXH3FS3jwYbpz_A,2327
15
+ codemie_sdk/models/workflow_state.py,sha256=CMYFQZ7sy4QxmnWmc83TFfqP7TG_3rW5MdH5fxsS9kY,1251
15
16
  codemie_sdk/services/assistant.py,sha256=-U5YpqOyKlVplSRPrnDItG8TUpg9qqhO6-F7c7Rz2xU,5110
16
17
  codemie_sdk/services/datasource.py,sha256=hYH__M5LD33dfh7CCS7HYmEn8izsGkO0nfVa-dpoj6w,5118
17
18
  codemie_sdk/services/integration.py,sha256=vJnSkXk2C2l0ahX2SUsuA7fKhY2hTuAByynx5Lgh7Ls,4864
@@ -19,9 +20,10 @@ codemie_sdk/services/llm.py,sha256=0-e4_7RvLHs2giCyoQ5U4KDTh6p5VXgPKNxnDP9ZDFU,1
19
20
  codemie_sdk/services/task.py,sha256=3e9t8_LMkR4xfeMBwMCo7ZF87PxPS-ZbzDg85ilda2M,1031
20
21
  codemie_sdk/services/user.py,sha256=7B-Qw451qKPD5Io6qLda-kbFDaPRQ3TamJamiGwCQu4,1013
21
22
  codemie_sdk/services/workflow.py,sha256=aOV13WrFAqMXOPd2jVHbEhg3fpezk4XWo382D5aWtro,4833
22
- codemie_sdk/services/workflow_execution.py,sha256=Ud-cYC_a2yb3FErfwWjM7hBIHzs2QoYQ-kX-o7K1cms,3152
23
+ codemie_sdk/services/workflow_execution.py,sha256=aGoT3rdTmh5-doAsrmBBjLEuOfvL5aqeo3g9th1_aAw,3647
24
+ codemie_sdk/services/workflow_execution_state.py,sha256=tXoaa8yT09xgYEUNiHhVULe76TwGwVgZupMIUyyLxdo,2070
23
25
  codemie_sdk/utils/__init__.py,sha256=BXAJJfAzO89-kMYvWWo9wSNhSbGgF3vB1In9sePFhMM,109
24
- codemie_sdk/utils/http.py,sha256=d2GRkd-OBrrrURfVLeD7SUGFsyB4k1anYz5LXX3o4H8,7525
25
- codemie_sdk_python-0.1.5.dist-info/METADATA,sha256=K_V1NJ4kJcm3JNpxU3j7ddJU5qmI_MC6NxjsJqh-etE,18940
26
- codemie_sdk_python-0.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
27
- codemie_sdk_python-0.1.5.dist-info/RECORD,,
26
+ codemie_sdk/utils/http.py,sha256=JfyX4gP-grQUI795QL0DJ72aBkiqNd1fs31fUqtSnYE,7757
27
+ codemie_sdk_python-0.1.6.dist-info/METADATA,sha256=bFS58qIKO7ZXcvu_L3QilTaE9tEV8hh8gQt4x-sqT6I,21439
28
+ codemie_sdk_python-0.1.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
+ codemie_sdk_python-0.1.6.dist-info/RECORD,,