codemie-sdk-python 0.1.1__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 +23 -0
- codemie_sdk/auth/__init__.py +5 -0
- codemie_sdk/auth/credentials.py +112 -0
- codemie_sdk/client/__init__.py +5 -0
- codemie_sdk/client/client.py +107 -0
- codemie_sdk/exceptions.py +45 -0
- codemie_sdk/models/assistant.py +192 -0
- codemie_sdk/models/common.py +39 -0
- codemie_sdk/models/datasource.py +293 -0
- codemie_sdk/models/integration.py +68 -0
- codemie_sdk/models/llm.py +48 -0
- codemie_sdk/models/task.py +44 -0
- codemie_sdk/models/user.py +50 -0
- codemie_sdk/models/workflow.py +86 -0
- codemie_sdk/services/assistant.py +173 -0
- codemie_sdk/services/datasource.py +150 -0
- codemie_sdk/services/integration.py +152 -0
- codemie_sdk/services/llm.py +38 -0
- codemie_sdk/services/task.py +34 -0
- codemie_sdk/services/user.py +34 -0
- codemie_sdk/services/workflow.py +144 -0
- codemie_sdk/services/workflow_execution.py +102 -0
- codemie_sdk/utils/__init__.py +5 -0
- codemie_sdk/utils/http.py +226 -0
- codemie_sdk_python-0.1.1.dist-info/LICENSE +19 -0
- codemie_sdk_python-0.1.1.dist-info/METADATA +120 -0
- codemie_sdk_python-0.1.1.dist-info/RECORD +28 -0
- codemie_sdk_python-0.1.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""Workflow service implementation."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from .workflow_execution import WorkflowExecutionService
|
|
7
|
+
from ..models.common import PaginationParams
|
|
8
|
+
from ..models.workflow import (
|
|
9
|
+
WorkflowCreateRequest,
|
|
10
|
+
WorkflowUpdateRequest,
|
|
11
|
+
Workflow,
|
|
12
|
+
)
|
|
13
|
+
from ..utils import ApiRequestHandler
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WorkflowService:
|
|
17
|
+
"""Service for managing CodeMie workflows."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
20
|
+
"""Initialize the workflow service.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
api_domain: Base URL for the CodeMie API
|
|
24
|
+
token: Authentication token
|
|
25
|
+
verify_ssl: Whether to verify SSL certificates
|
|
26
|
+
"""
|
|
27
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
28
|
+
|
|
29
|
+
def get_prebuilt(self) -> List[Workflow]:
|
|
30
|
+
"""Get list of prebuilt workflows.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
List of prebuilt workflow templates
|
|
34
|
+
"""
|
|
35
|
+
return self._api.get("/v1/workflows/prebuilt", List[Workflow])
|
|
36
|
+
|
|
37
|
+
def create_workflow(self, request: WorkflowCreateRequest) -> dict:
|
|
38
|
+
"""Create a new workflow.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
request: The workflow creation request containing required fields:
|
|
42
|
+
- name: Name of the workflow
|
|
43
|
+
- description: Description of the workflow
|
|
44
|
+
- project: Project identifier
|
|
45
|
+
- yaml_config: YAML configuration for the workflow
|
|
46
|
+
Optional fields with defaults:
|
|
47
|
+
- mode: WorkflowMode (defaults to SEQUENTIAL)
|
|
48
|
+
- shared: bool (defaults to False)
|
|
49
|
+
- icon_url: Optional URL for workflow icon
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Created WorkflowTemplate instance
|
|
53
|
+
"""
|
|
54
|
+
return self._api.post("/v1/workflows", dict, json_data=request.model_dump())
|
|
55
|
+
|
|
56
|
+
def update(self, workflow_id: str, request: WorkflowUpdateRequest) -> dict:
|
|
57
|
+
"""Update an existing workflow.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
workflow_id: ID of the workflow to update
|
|
61
|
+
request: The workflow update request containing optional fields to update:
|
|
62
|
+
- name: New name for the workflow
|
|
63
|
+
- description: New description
|
|
64
|
+
- yaml_config: New YAML configuration
|
|
65
|
+
- mode: New workflow mode
|
|
66
|
+
- shared: New sharing status
|
|
67
|
+
- icon_url: New icon URL
|
|
68
|
+
Only specified fields will be updated.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Updated WorkflowTemplate instance
|
|
72
|
+
"""
|
|
73
|
+
return self._api.put(
|
|
74
|
+
f"/v1/workflows/{workflow_id}",
|
|
75
|
+
dict,
|
|
76
|
+
json_data=request.model_dump(exclude_none=True),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def list(
|
|
80
|
+
self,
|
|
81
|
+
page: int = 0,
|
|
82
|
+
per_page: int = 10,
|
|
83
|
+
projects: Optional[List[str]] = None,
|
|
84
|
+
) -> List[Workflow]:
|
|
85
|
+
"""List workflows with filtering and pagination support.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
page: Page number (0-based). Must be >= 0. Defaults to 0.
|
|
89
|
+
per_page: Number of items per page. Must be > 0. Defaults to 10.
|
|
90
|
+
projects: Optional projects to filter by.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
List of Workflow objects containing workflow information and pagination metadata.
|
|
94
|
+
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
params = PaginationParams(page=page, per_page=per_page).to_dict()
|
|
98
|
+
|
|
99
|
+
filters = {}
|
|
100
|
+
if projects:
|
|
101
|
+
filters["project"] = projects
|
|
102
|
+
if filters:
|
|
103
|
+
params["filters"] = json.dumps(filters)
|
|
104
|
+
|
|
105
|
+
return self._api.get("/v1/workflows", List[Workflow], params=params)
|
|
106
|
+
|
|
107
|
+
def get(self, workflow_id: str) -> Workflow:
|
|
108
|
+
"""Get workflow by ID.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
workflow_id: The ID of the workflow to retrieve.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Workflow object containing the workflow information.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ApiError: If the workflow is not found or other API errors occur.
|
|
118
|
+
"""
|
|
119
|
+
return self._api.get(f"/v1/workflows/id/{workflow_id}", Workflow)
|
|
120
|
+
|
|
121
|
+
def delete(self, workflow_id: str) -> dict:
|
|
122
|
+
"""Delete a workflow by ID.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
workflow_id: ID of the workflow to delete
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Deletion confirmation
|
|
129
|
+
"""
|
|
130
|
+
return self._api.delete(f"/v1/workflows/{workflow_id}", dict)
|
|
131
|
+
|
|
132
|
+
def run(self, workflow_id: str, user_input: str = "") -> dict:
|
|
133
|
+
return self.executions(workflow_id).create(user_input)
|
|
134
|
+
|
|
135
|
+
def executions(self, workflow_id: str) -> WorkflowExecutionService:
|
|
136
|
+
"""Get workflow execution service for the specified workflow.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
workflow_id: ID of the workflow to manage executions for
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
WorkflowExecutionService instance configured for the specified workflow
|
|
143
|
+
"""
|
|
144
|
+
return WorkflowExecutionService(self._api, workflow_id)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Workflow execution service implementation."""
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from ..models.common import PaginationParams
|
|
6
|
+
from ..models.workflow import WorkflowExecution
|
|
7
|
+
from ..utils import ApiRequestHandler
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WorkflowExecutionService:
|
|
11
|
+
"""Service for managing workflow executions."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, api: ApiRequestHandler, workflow_id: str):
|
|
14
|
+
"""Initialize the workflow execution service.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
api: Request handler for API
|
|
18
|
+
workflow_id: ID of the workflow this service manages executions for
|
|
19
|
+
"""
|
|
20
|
+
self._api = api
|
|
21
|
+
self._workflow_id = workflow_id
|
|
22
|
+
|
|
23
|
+
def list(
|
|
24
|
+
self,
|
|
25
|
+
page: int = 0,
|
|
26
|
+
per_page: int = 10,
|
|
27
|
+
) -> List[WorkflowExecution]:
|
|
28
|
+
"""List executions for the workflow with filtering and pagination support.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
page: Page number (0-based). Must be >= 0. Defaults to 0.
|
|
32
|
+
per_page: Number of items per page. Must be > 0. Defaults to 10.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
List of WorkflowExecutions containing execution information.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
params = PaginationParams(page=page, per_page=per_page).to_dict()
|
|
39
|
+
return self._api.get(
|
|
40
|
+
f"/v1/workflows/{self._workflow_id}/executions",
|
|
41
|
+
List[WorkflowExecution],
|
|
42
|
+
params=params,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
def create(self, user_input: Optional[str] = "") -> dict:
|
|
46
|
+
"""Create a new workflow execution.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
user_input: Optional input data for the workflow execution.
|
|
50
|
+
Defaults to None.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
dict: Created workflow execution details
|
|
54
|
+
"""
|
|
55
|
+
payload = {"user_input": user_input}
|
|
56
|
+
return self._api.post(
|
|
57
|
+
f"/v1/workflows/{self._workflow_id}/executions", dict, json_data=payload
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def get(self, execution_id: str) -> WorkflowExecution:
|
|
61
|
+
"""Get workflow execution by ID.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
execution_id: ID of the execution to retrieve
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
dict: Workflow execution details
|
|
68
|
+
"""
|
|
69
|
+
return self._api.get(
|
|
70
|
+
f"/v1/workflows/{self._workflow_id}/executions/{execution_id}",
|
|
71
|
+
WorkflowExecution,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def delete_all(self) -> dict:
|
|
75
|
+
"""Delete all workflow executions."""
|
|
76
|
+
return self._api.delete(f"/v1/workflows/{self._workflow_id}/executions", dict)
|
|
77
|
+
|
|
78
|
+
def abort(self, execution_id: str) -> dict:
|
|
79
|
+
"""Abort a running workflow execution.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
execution_id: ID of the execution to abort
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
dict: Updated workflow execution details
|
|
86
|
+
"""
|
|
87
|
+
return self._api.put(
|
|
88
|
+
f"/v1/workflows/{self._workflow_id}/executions/{execution_id}/abort", dict
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def resume(self, execution_id: str) -> dict:
|
|
92
|
+
"""Resume an interrupted workflow execution.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
execution_id: ID of the execution to resume
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
dict: Updated workflow execution details
|
|
99
|
+
"""
|
|
100
|
+
return self._api.put(
|
|
101
|
+
f"/v1/workflows/{self._workflow_id}/executions/{execution_id}/resume", dict
|
|
102
|
+
)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"""HTTP utilities for CodeMie SDK."""
|
|
2
|
+
|
|
3
|
+
from typing import TypeVar, Type, Optional, Any, Union, Dict, List, get_origin, get_args
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
import requests
|
|
6
|
+
import logging
|
|
7
|
+
from functools import wraps
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound=Union[BaseModel, List[BaseModel], dict])
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def log_request(func):
|
|
15
|
+
"""Decorator to log request details"""
|
|
16
|
+
|
|
17
|
+
@wraps(func)
|
|
18
|
+
def wrapper(self, *args, **kwargs):
|
|
19
|
+
method = kwargs.get("method", args[0] if args else None)
|
|
20
|
+
endpoint = kwargs.get("endpoint", args[1] if len(args) > 1 else None)
|
|
21
|
+
logger.debug(f"Making {method} request to {self._base_url}{endpoint}")
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
result = func(self, *args, **kwargs)
|
|
25
|
+
logger.info(f"Successfully processed {method} request to {endpoint}")
|
|
26
|
+
return result
|
|
27
|
+
except Exception as e:
|
|
28
|
+
logger.error(f"Error during {method} request to {endpoint}: {str(e)}")
|
|
29
|
+
raise
|
|
30
|
+
|
|
31
|
+
return wrapper
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ApiRequestHandler:
|
|
35
|
+
"""Handles HTTP requests with consistent error handling and response parsing."""
|
|
36
|
+
|
|
37
|
+
def __init__(self, base_url: str, token: str, verify_ssl: bool = True):
|
|
38
|
+
"""Initialize the API request handler.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
base_url: Base URL for the API
|
|
42
|
+
token: Authentication token
|
|
43
|
+
verify_ssl: Whether to verify SSL certificates
|
|
44
|
+
"""
|
|
45
|
+
self._base_url = base_url.rstrip("/")
|
|
46
|
+
self._token = token
|
|
47
|
+
self._verify_ssl = verify_ssl
|
|
48
|
+
|
|
49
|
+
def _get_headers(self) -> dict:
|
|
50
|
+
"""Gets request headers with auth token."""
|
|
51
|
+
return {
|
|
52
|
+
"Authorization": f"Bearer {self._token}",
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def _parse_response(
|
|
57
|
+
self,
|
|
58
|
+
response: requests.Response,
|
|
59
|
+
response_model: Type[T],
|
|
60
|
+
wrap_response: bool = True,
|
|
61
|
+
) -> T:
|
|
62
|
+
"""Parse response data into model, handling both single models and lists.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
response: Response from requests
|
|
66
|
+
response_model: Type to parse into (can be a single model or List[model])
|
|
67
|
+
wrap_response: Whether response is wrapped in 'data' field
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Parsed response object or list of objects
|
|
71
|
+
"""
|
|
72
|
+
try:
|
|
73
|
+
response_data = response.json()
|
|
74
|
+
logger.debug(f"Received response with status {response.status_code}")
|
|
75
|
+
logger.debug(f"Response datasource_type: {type(response_data)}")
|
|
76
|
+
|
|
77
|
+
# Handle data wrapper for dict responses only
|
|
78
|
+
if wrap_response and isinstance(response_data, dict):
|
|
79
|
+
response_data = response_data.get("data", response_data)
|
|
80
|
+
|
|
81
|
+
# If response_model is dict, return raw data
|
|
82
|
+
if response_model is dict:
|
|
83
|
+
return response_data
|
|
84
|
+
|
|
85
|
+
# Handle List types
|
|
86
|
+
origin = get_origin(response_model)
|
|
87
|
+
if origin is list:
|
|
88
|
+
# Get the model class from List[Model]
|
|
89
|
+
model_class = get_args(response_model)[0]
|
|
90
|
+
if not isinstance(response_data, list):
|
|
91
|
+
response_data = [response_data]
|
|
92
|
+
return [model_class.model_validate(item) for item in response_data]
|
|
93
|
+
else:
|
|
94
|
+
# Handle single model
|
|
95
|
+
return response_model.model_validate(response_data)
|
|
96
|
+
|
|
97
|
+
except ValueError as e:
|
|
98
|
+
logger.error(f"Failed to parse response: {str(e)}")
|
|
99
|
+
raise
|
|
100
|
+
except Exception as e:
|
|
101
|
+
logger.error(f"Unexpected error parsing response: {str(e)}")
|
|
102
|
+
raise
|
|
103
|
+
|
|
104
|
+
@log_request
|
|
105
|
+
def get(
|
|
106
|
+
self,
|
|
107
|
+
endpoint: str,
|
|
108
|
+
response_model: Type[T],
|
|
109
|
+
params: Optional[Dict[str, Any]] = None,
|
|
110
|
+
wrap_response: bool = True,
|
|
111
|
+
) -> T:
|
|
112
|
+
"""Makes a GET request and parses the response.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
endpoint: API endpoint path
|
|
116
|
+
response_model: Pydantic model class or List[Model] for response
|
|
117
|
+
params: Query parameters
|
|
118
|
+
wrap_response: Whether response is wrapped in 'data' field
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
Parsed response object or list of objects
|
|
122
|
+
"""
|
|
123
|
+
if params:
|
|
124
|
+
logger.debug(f"Request params: {params}")
|
|
125
|
+
response = requests.get(
|
|
126
|
+
url=f"{self._base_url}{endpoint}",
|
|
127
|
+
headers=self._get_headers(),
|
|
128
|
+
params=params,
|
|
129
|
+
verify=self._verify_ssl,
|
|
130
|
+
)
|
|
131
|
+
response.raise_for_status()
|
|
132
|
+
|
|
133
|
+
return self._parse_response(response, response_model, wrap_response)
|
|
134
|
+
|
|
135
|
+
@log_request
|
|
136
|
+
def post(
|
|
137
|
+
self,
|
|
138
|
+
endpoint: str,
|
|
139
|
+
response_model: Type[T],
|
|
140
|
+
json_data: Optional[Dict[str, Any]] = None,
|
|
141
|
+
stream: bool = False,
|
|
142
|
+
wrap_response: bool = True,
|
|
143
|
+
) -> Union[T, requests.Response]:
|
|
144
|
+
"""Makes a POST request and parses the response.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
endpoint: API endpoint path
|
|
148
|
+
response_model: Pydantic model class or List[Model] for response
|
|
149
|
+
json_data: JSON request body
|
|
150
|
+
stream: Whether to return streaming response
|
|
151
|
+
wrap_response: Whether response is wrapped in 'data' field
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
Parsed response object/list or streaming response
|
|
155
|
+
"""
|
|
156
|
+
if json_data:
|
|
157
|
+
logger.debug(f"Request body: {json_data}")
|
|
158
|
+
|
|
159
|
+
response = requests.post(
|
|
160
|
+
url=f"{self._base_url}{endpoint}",
|
|
161
|
+
headers=self._get_headers(),
|
|
162
|
+
json=json_data,
|
|
163
|
+
verify=self._verify_ssl,
|
|
164
|
+
stream=stream,
|
|
165
|
+
)
|
|
166
|
+
response.raise_for_status()
|
|
167
|
+
|
|
168
|
+
if stream:
|
|
169
|
+
return response
|
|
170
|
+
|
|
171
|
+
return self._parse_response(response, response_model, wrap_response)
|
|
172
|
+
|
|
173
|
+
@log_request
|
|
174
|
+
def put(
|
|
175
|
+
self,
|
|
176
|
+
endpoint: str,
|
|
177
|
+
response_model: Type[T],
|
|
178
|
+
json_data: Dict[str, Any],
|
|
179
|
+
params: Optional[Dict[str, Any]] = None,
|
|
180
|
+
wrap_response: bool = True,
|
|
181
|
+
) -> T:
|
|
182
|
+
"""Makes a PUT request and parses the response.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
endpoint: API endpoint path
|
|
186
|
+
response_model: Pydantic model class or List[Model] for response
|
|
187
|
+
json_data: JSON request body
|
|
188
|
+
params: Query parameters
|
|
189
|
+
wrap_response: Whether response is wrapped in 'data' field
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
Parsed response object or list of objects
|
|
193
|
+
"""
|
|
194
|
+
logger.debug(f"Request body: {json_data}")
|
|
195
|
+
response = requests.put(
|
|
196
|
+
url=f"{self._base_url}{endpoint}",
|
|
197
|
+
headers=self._get_headers(),
|
|
198
|
+
json=json_data,
|
|
199
|
+
params=params,
|
|
200
|
+
verify=self._verify_ssl,
|
|
201
|
+
)
|
|
202
|
+
response.raise_for_status()
|
|
203
|
+
return self._parse_response(response, response_model, wrap_response)
|
|
204
|
+
|
|
205
|
+
@log_request
|
|
206
|
+
def delete(
|
|
207
|
+
self, endpoint: str, response_model: Type[T], wrap_response: bool = True
|
|
208
|
+
) -> T:
|
|
209
|
+
"""Makes a DELETE request and parses the response.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
endpoint: API endpoint path
|
|
213
|
+
response_model: Pydantic model class or List[Model] for response
|
|
214
|
+
wrap_response: Whether response is wrapped in 'data' field
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
Parsed response object or list of objects
|
|
218
|
+
"""
|
|
219
|
+
response = requests.delete(
|
|
220
|
+
url=f"{self._base_url}{endpoint}",
|
|
221
|
+
headers=self._get_headers(),
|
|
222
|
+
verify=self._verify_ssl,
|
|
223
|
+
)
|
|
224
|
+
response.raise_for_status()
|
|
225
|
+
|
|
226
|
+
return self._parse_response(response, response_model, wrap_response)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: codemie-sdk-python
|
|
3
|
+
Version: 0.1.1
|
|
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.6.1,<3.0.0)
|
|
11
|
+
Requires-Dist: pytest-cov (>=6.0.0,<7.0.0)
|
|
12
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
13
|
+
Requires-Dist: ruff (>=0.11.0,<0.12.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# CodeMie Python SDK
|
|
17
|
+
|
|
18
|
+
Python SDK for CodeMie services
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pip install codemie-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Basic usage
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from codemie_sdk import CodeMieClient
|
|
33
|
+
|
|
34
|
+
# Initialize client with authentication parameters
|
|
35
|
+
client = CodeMieClient(
|
|
36
|
+
auth_server_url="https://keycloak.example.com",
|
|
37
|
+
auth_client_id="your-client-id",
|
|
38
|
+
auth_client_secret="your-client-secret",
|
|
39
|
+
auth_realm_name="your-realm",
|
|
40
|
+
codemie_api_domain="https://codemie-preview.lab.epam.com/code-assistant-api"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Create a new workflow
|
|
44
|
+
workflow = client.workflow.create('project-id', 'workflow-name', {'param': 'value'}, token=client.token)
|
|
45
|
+
|
|
46
|
+
# Execute tool
|
|
47
|
+
tool_result = client.tool.execute(
|
|
48
|
+
tool_name='my-tool',
|
|
49
|
+
project='project-id',
|
|
50
|
+
tool_args={'param': 'value'},
|
|
51
|
+
token=client.token
|
|
52
|
+
)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Tool Operations
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
# List available tools
|
|
59
|
+
tools = client.tool.list(token=client.token)
|
|
60
|
+
|
|
61
|
+
# Get tool schema
|
|
62
|
+
schema = client.tool.schema('tool-name', token=client.token)
|
|
63
|
+
|
|
64
|
+
# Execute tool with optional parameters
|
|
65
|
+
result = client.tool.execute(
|
|
66
|
+
tool_name='my-tool',
|
|
67
|
+
project='project-id',
|
|
68
|
+
tool_args={'param': 'value'},
|
|
69
|
+
token=client.token,
|
|
70
|
+
llm_model='gpt-4', # optional
|
|
71
|
+
tool_attributes={'attr': 'value'}, # optional
|
|
72
|
+
tool_creds={'cred': 'secret'}, # optional
|
|
73
|
+
datasource_id='ds-123', # optional
|
|
74
|
+
params={'retry_count': 3} # optional
|
|
75
|
+
)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Workflow Operations
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Create workflow
|
|
82
|
+
workflow = client.workflow.create('project-id', 'workflow-name', {'param': 'value'}, token=client.token)
|
|
83
|
+
|
|
84
|
+
# Get workflow status
|
|
85
|
+
status = client.workflow.status('workflow-id', token=client.token)
|
|
86
|
+
|
|
87
|
+
# List workflows
|
|
88
|
+
workflows = client.workflow.list('project-id', token=client.token)
|
|
89
|
+
|
|
90
|
+
# Get workflow result
|
|
91
|
+
result = client.workflow.result('workflow-id', token=client.token)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
### Setup
|
|
97
|
+
|
|
98
|
+
1. Create and activate virtual environment:
|
|
99
|
+
```sh
|
|
100
|
+
python -m venv venv
|
|
101
|
+
source venv/bin/activate # Linux/MacOS
|
|
102
|
+
venv\Scripts\activate # Windows
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. Install dependencies:
|
|
106
|
+
```sh
|
|
107
|
+
pip install -r requirements.txt
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Running Tests
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
make test
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Building Package
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
make build
|
|
120
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
codemie_sdk/__init__.py,sha256=xfhrTFdvRmLSsrdQksX5GhnoQEj6tvkeytkrbB20Jj8,567
|
|
2
|
+
codemie_sdk/auth/__init__.py,sha256=IksEj223xEZtJ-cQ0AT9L0Bs9psIJ8QNzDXrPTUQ3xQ,126
|
|
3
|
+
codemie_sdk/auth/credentials.py,sha256=u2eLNsD8fELTgreQghVb0g0kk82zchUkux0M5lzq-u8,4320
|
|
4
|
+
codemie_sdk/client/__init__.py,sha256=yf6C39MmrJ6gK9ZHMhBeynKwUUYVSUTQbKxU8-4qpKg,101
|
|
5
|
+
codemie_sdk/client/client.py,sha256=aU4yr_Un4gX7SLXZ7rQiO_ObxE2__RyR8OdlxeKLRvc,4172
|
|
6
|
+
codemie_sdk/exceptions.py,sha256=XoVPyognx-JmyVxLHkZPAcX1CMi1OoT1diBFJLU54so,1183
|
|
7
|
+
codemie_sdk/models/assistant.py,sha256=hx3R1H7UPqRvmBFKL7PDwHdVcX_CbjUsju55tjVRVEo,5538
|
|
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
|
|
11
|
+
codemie_sdk/models/llm.py,sha256=ppb9-1dx1UFhRuJpSR3ij7H6Pfhe9nO4C4BEOIbToy4,1192
|
|
12
|
+
codemie_sdk/models/task.py,sha256=J4ZFRY3s8qBGrqB5NLQF0rMbInLh4s7OEZ0ZfmnW0Ho,1476
|
|
13
|
+
codemie_sdk/models/user.py,sha256=Q0rjimZh-IbeaPfq6b6fk6ZaCtwLqWHEIlU863suCS4,1777
|
|
14
|
+
codemie_sdk/models/workflow.py,sha256=CyK-kBnOck2KiRX3gmWF_mcGtqxsGXH3FS3jwYbpz_A,2327
|
|
15
|
+
codemie_sdk/services/assistant.py,sha256=-U5YpqOyKlVplSRPrnDItG8TUpg9qqhO6-F7c7Rz2xU,5110
|
|
16
|
+
codemie_sdk/services/datasource.py,sha256=hYH__M5LD33dfh7CCS7HYmEn8izsGkO0nfVa-dpoj6w,5118
|
|
17
|
+
codemie_sdk/services/integration.py,sha256=vJnSkXk2C2l0ahX2SUsuA7fKhY2hTuAByynx5Lgh7Ls,4864
|
|
18
|
+
codemie_sdk/services/llm.py,sha256=0-e4_7RvLHs2giCyoQ5U4KDTh6p5VXgPKNxnDP9ZDFU,1100
|
|
19
|
+
codemie_sdk/services/task.py,sha256=3e9t8_LMkR4xfeMBwMCo7ZF87PxPS-ZbzDg85ilda2M,1031
|
|
20
|
+
codemie_sdk/services/user.py,sha256=7B-Qw451qKPD5Io6qLda-kbFDaPRQ3TamJamiGwCQu4,1013
|
|
21
|
+
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/utils/__init__.py,sha256=BXAJJfAzO89-kMYvWWo9wSNhSbGgF3vB1In9sePFhMM,109
|
|
24
|
+
codemie_sdk/utils/http.py,sha256=d2GRkd-OBrrrURfVLeD7SUGFsyB4k1anYz5LXX3o4H8,7525
|
|
25
|
+
codemie_sdk_python-0.1.1.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
26
|
+
codemie_sdk_python-0.1.1.dist-info/METADATA,sha256=pHfmSlkVSpTP7Qb2ESgrpP4_jzvUxNeSF6FSt0E8_es,2633
|
|
27
|
+
codemie_sdk_python-0.1.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
28
|
+
codemie_sdk_python-0.1.1.dist-info/RECORD,,
|