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,173 @@
|
|
|
1
|
+
"""Assistant service implementation."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import List, Union, Optional, Dict, Any, Literal
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from ..models.assistant import (
|
|
9
|
+
Assistant,
|
|
10
|
+
AssistantCreateRequest,
|
|
11
|
+
AssistantUpdateRequest,
|
|
12
|
+
ToolKitDetails,
|
|
13
|
+
AssistantChatRequest,
|
|
14
|
+
BaseModelResponse,
|
|
15
|
+
AssistantBase,
|
|
16
|
+
)
|
|
17
|
+
from ..models.common import PaginationParams
|
|
18
|
+
from ..utils import ApiRequestHandler
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AssistantService:
|
|
22
|
+
"""Service for managing CodeMie assistants."""
|
|
23
|
+
|
|
24
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
25
|
+
"""Initialize the assistant service.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
api_domain: Base URL for the CodeMie API
|
|
29
|
+
token: Authentication token
|
|
30
|
+
verify_ssl: Whether to verify SSL certificates
|
|
31
|
+
"""
|
|
32
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
33
|
+
|
|
34
|
+
def list(
|
|
35
|
+
self,
|
|
36
|
+
minimal_response: bool = True,
|
|
37
|
+
scope: Literal["visible_to_user", "created_by_user"] = "visible_to_user",
|
|
38
|
+
page: int = 0,
|
|
39
|
+
per_page: int = 12,
|
|
40
|
+
filters: Optional[Dict[str, Any]] = None,
|
|
41
|
+
) -> List[Union[Assistant, AssistantBase]]:
|
|
42
|
+
"""Get list of available assistants.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
minimal_response: Whether to return minimal assistant info
|
|
46
|
+
scope: Visibility scope of assistants to retrieve
|
|
47
|
+
page: Page number for pagination
|
|
48
|
+
per_page: Number of items per page
|
|
49
|
+
filters: Optional filters to apply
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
List of assistants matching the criteria
|
|
53
|
+
"""
|
|
54
|
+
params = PaginationParams(page=page, per_page=per_page).to_dict()
|
|
55
|
+
params["scope"] = scope
|
|
56
|
+
params["minimal_response"] = minimal_response
|
|
57
|
+
if filters:
|
|
58
|
+
params["filters"] = json.dumps(filters)
|
|
59
|
+
|
|
60
|
+
model = AssistantBase if minimal_response else Assistant
|
|
61
|
+
return self._api.get("/v1/assistants", List[model], params=params)
|
|
62
|
+
|
|
63
|
+
def get(self, assistant_id: str) -> Assistant:
|
|
64
|
+
"""Get assistant by ID.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
assistant_id: ID of the assistant to retrieve
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Assistant details
|
|
71
|
+
"""
|
|
72
|
+
return self._api.get(f"/v1/assistants/id/{assistant_id}", Assistant)
|
|
73
|
+
|
|
74
|
+
def get_by_slug(self, slug: str) -> Assistant:
|
|
75
|
+
"""Get assistant by slug.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
slug: Slug of the assistant to retrieve
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
Assistant details
|
|
82
|
+
"""
|
|
83
|
+
return self._api.get(f"/v1/assistants/slug/{slug}", Assistant)
|
|
84
|
+
|
|
85
|
+
def create(self, request: AssistantCreateRequest) -> dict:
|
|
86
|
+
"""Create a new assistant.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
request: Assistant creation request
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Created assistant details
|
|
93
|
+
"""
|
|
94
|
+
return self._api.post(
|
|
95
|
+
"/v1/assistants", dict, json_data=request.model_dump(exclude_none=True)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def update(self, assistant_id: str, request: AssistantUpdateRequest) -> dict:
|
|
99
|
+
"""Update an existing assistant.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
assistant_id: ID of the assistant to update
|
|
103
|
+
request: Assistant update request
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Updated assistant details
|
|
107
|
+
"""
|
|
108
|
+
return self._api.put(
|
|
109
|
+
f"/v1/assistants/{assistant_id}",
|
|
110
|
+
dict,
|
|
111
|
+
json_data=request.model_dump(exclude_none=True),
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def get_tools(self) -> List[ToolKitDetails]:
|
|
115
|
+
"""Get list of available tools.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
List of available tool kits
|
|
119
|
+
"""
|
|
120
|
+
return self._api.get(
|
|
121
|
+
"/v1/assistants/tools", List[ToolKitDetails], wrap_response=False
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def delete(self, assistant_id: str) -> dict:
|
|
125
|
+
"""Delete an assistant by ID.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
assistant_id: ID of the assistant to delete
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Deletion confirmation
|
|
132
|
+
"""
|
|
133
|
+
return self._api.delete(f"/v1/assistants/{assistant_id}", dict)
|
|
134
|
+
|
|
135
|
+
def get_prebuilt(self) -> List[Assistant]:
|
|
136
|
+
"""Get list of prebuilt assistants.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
List of prebuilt assistants
|
|
140
|
+
"""
|
|
141
|
+
return self._api.get("/v1/assistants/prebuilt", List[Assistant])
|
|
142
|
+
|
|
143
|
+
def get_prebuilt_by_slug(self, slug: str) -> Assistant:
|
|
144
|
+
"""Get prebuilt assistant by slug.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
slug: Slug of the prebuilt assistant to retrieve
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Prebuilt assistant details
|
|
151
|
+
"""
|
|
152
|
+
return self._api.get(f"/v1/assistants/prebuilt/{slug}", Assistant)
|
|
153
|
+
|
|
154
|
+
def chat(
|
|
155
|
+
self,
|
|
156
|
+
assistant_id: str,
|
|
157
|
+
request: AssistantChatRequest,
|
|
158
|
+
) -> Union[requests.Response, BaseModelResponse]:
|
|
159
|
+
"""Send a chat request to an assistant.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
assistant_id: ID of the assistant to chat with
|
|
163
|
+
request: Chat request details
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
Chat response or streaming response
|
|
167
|
+
"""
|
|
168
|
+
return self._api.post(
|
|
169
|
+
f"/v1/assistants/{assistant_id}/model",
|
|
170
|
+
BaseModelResponse,
|
|
171
|
+
json_data=request.model_dump(exclude_none=True, by_alias=True),
|
|
172
|
+
stream=request.stream,
|
|
173
|
+
)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""DataSource service implementation."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Literal, List
|
|
5
|
+
|
|
6
|
+
from ..models.common import PaginationParams
|
|
7
|
+
from ..models.datasource import (
|
|
8
|
+
DataSource,
|
|
9
|
+
DataSourceType,
|
|
10
|
+
DataSourceStatus,
|
|
11
|
+
BaseDataSourceRequest,
|
|
12
|
+
CodeDataSourceRequest,
|
|
13
|
+
UpdateCodeDataSourceRequest,
|
|
14
|
+
BaseUpdateDataSourceRequest,
|
|
15
|
+
)
|
|
16
|
+
from ..utils import ApiRequestHandler
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DatasourceService:
|
|
20
|
+
"""Service for managing CodeMie Datasources."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
23
|
+
"""Initialize the datasource service.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
api_domain: Base URL for the CodeMie API
|
|
27
|
+
token: Authentication token
|
|
28
|
+
verify_ssl: Whether to verify SSL certificates
|
|
29
|
+
"""
|
|
30
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
31
|
+
|
|
32
|
+
def create(self, request: BaseDataSourceRequest) -> dict:
|
|
33
|
+
"""Create a new datasource.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
request: Create datasource request
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
dict: Response from the server containing operation status
|
|
40
|
+
"""
|
|
41
|
+
if isinstance(request, CodeDataSourceRequest):
|
|
42
|
+
endpoint = f"/v1/application/{request.project_name}/index"
|
|
43
|
+
else:
|
|
44
|
+
# All other datasources follow the same pattern
|
|
45
|
+
endpoint = f"/v1/index/knowledge_base/{request.type.name.lower()}"
|
|
46
|
+
|
|
47
|
+
return self._api.post(
|
|
48
|
+
endpoint,
|
|
49
|
+
dict,
|
|
50
|
+
json_data=request.model_dump(by_alias=True, exclude_none=True),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def update(self, datasource_id: str, request: BaseUpdateDataSourceRequest) -> dict:
|
|
54
|
+
"""Update an existing datasource.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
request: Update datasource request
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
dict: Response from the server containing operation status
|
|
61
|
+
"""
|
|
62
|
+
if isinstance(request, UpdateCodeDataSourceRequest):
|
|
63
|
+
endpoint = f"/v1/application/{request.project_name}/index/{request.name}"
|
|
64
|
+
else:
|
|
65
|
+
endpoint = f"/v1/index/knowledge_base/{request.type.name.lower()}"
|
|
66
|
+
|
|
67
|
+
# Extract reindex params
|
|
68
|
+
params = {
|
|
69
|
+
"full_reindex": request.full_reindex,
|
|
70
|
+
"skip_reindex": request.skip_reindex,
|
|
71
|
+
"resume_indexing": request.resume_indexing,
|
|
72
|
+
"incremental_reindex": request.incremental_reindex,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Remove reindex fields from request body
|
|
76
|
+
data = request.model_dump(by_alias=True, exclude_none=True)
|
|
77
|
+
for param in params.keys():
|
|
78
|
+
data.pop(param, None)
|
|
79
|
+
|
|
80
|
+
return self._api.put(endpoint, dict, params=params, json_data=data)
|
|
81
|
+
|
|
82
|
+
def list(
|
|
83
|
+
self,
|
|
84
|
+
page: int = 0,
|
|
85
|
+
per_page: int = 10,
|
|
86
|
+
sort_key: Literal["date", "update_date"] = "update_date",
|
|
87
|
+
sort_order: Literal["asc", "desc"] = "desc",
|
|
88
|
+
datasource_types: List[DataSourceType] = None,
|
|
89
|
+
projects: List[str] = None,
|
|
90
|
+
owner: str = None,
|
|
91
|
+
status: DataSourceStatus = None,
|
|
92
|
+
) -> List[DataSource]:
|
|
93
|
+
"""
|
|
94
|
+
List datasources with pagination and sorting support.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
page: Page number (0-based). Defaults to 0.
|
|
98
|
+
per_page: Number of items per page. Defaults to 10.
|
|
99
|
+
sort_key: Field to sort by. Either "date" or "update_date". Defaults to "update_date".
|
|
100
|
+
sort_order: Sort order. Either "asc" or "desc". Defaults to "desc".
|
|
101
|
+
datasource_types: Optional data source types to filter by.
|
|
102
|
+
projects: Optional projects to filter by.
|
|
103
|
+
owner: Optional owner to filter by in format: FirstName LastName.
|
|
104
|
+
status: Optional data source status to filter by.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
DataSourceListResponse object containing list of datasources and pagination information.
|
|
108
|
+
"""
|
|
109
|
+
params = PaginationParams(page=page, per_page=per_page).to_dict()
|
|
110
|
+
params["sort_key"] = sort_key
|
|
111
|
+
params["sort_order"] = sort_order
|
|
112
|
+
|
|
113
|
+
filters = {}
|
|
114
|
+
if datasource_types:
|
|
115
|
+
filters["index_type"] = datasource_types
|
|
116
|
+
if projects:
|
|
117
|
+
filters["project"] = projects
|
|
118
|
+
if status:
|
|
119
|
+
filters["status"] = status.value
|
|
120
|
+
if owner:
|
|
121
|
+
filters["created_by"] = owner
|
|
122
|
+
if filters:
|
|
123
|
+
params["filters"] = json.dumps(filters)
|
|
124
|
+
return self._api.get("/v1/index", List[DataSource], params=params)
|
|
125
|
+
|
|
126
|
+
def get(self, datasource_id: str) -> DataSource:
|
|
127
|
+
"""
|
|
128
|
+
Get datasource by ID.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
datasource_id: The ID of the datasource to retrieve.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
DataSource object containing the datasource information.
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
ApiError: If the datasource is not found or other API errors occur.
|
|
138
|
+
"""
|
|
139
|
+
return self._api.get(f"/v1/index/{datasource_id}", DataSource)
|
|
140
|
+
|
|
141
|
+
def delete(self, datasource_id: str) -> dict:
|
|
142
|
+
"""Delete an datasource by ID.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
datasource_id: ID of the datasource to delete
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Deletion confirmation
|
|
149
|
+
"""
|
|
150
|
+
return self._api.delete(f"/v1/index/{datasource_id}", dict)
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Integration service implementation."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import List, Optional, Dict, Any
|
|
5
|
+
|
|
6
|
+
from ..exceptions import NotFoundError
|
|
7
|
+
from ..models.common import PaginationParams
|
|
8
|
+
from ..models.integration import Integration, IntegrationType
|
|
9
|
+
from ..utils import ApiRequestHandler
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class IntegrationService:
|
|
13
|
+
"""Service for managing CodeMie integrations (both user and project settings)."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
16
|
+
"""Initialize the integration service.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
api_domain: Base URL for the CodeMie API
|
|
20
|
+
token: Authentication token
|
|
21
|
+
verify_ssl: Whether to verify SSL certificates
|
|
22
|
+
"""
|
|
23
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
24
|
+
|
|
25
|
+
def _get_base_path(self, setting_type: IntegrationType) -> str:
|
|
26
|
+
"""Get base API path based on setting type.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
setting_type: Type of settings (USER or PROJECT)
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
Base API path for the specified setting type
|
|
33
|
+
"""
|
|
34
|
+
return f"/v1/settings/{'user' if setting_type == IntegrationType.USER else 'project'}"
|
|
35
|
+
|
|
36
|
+
def list(
|
|
37
|
+
self,
|
|
38
|
+
setting_type: IntegrationType = IntegrationType.USER,
|
|
39
|
+
page: int = 0,
|
|
40
|
+
per_page: int = 10,
|
|
41
|
+
filters: Optional[Dict[str, Any]] = None,
|
|
42
|
+
) -> List[Integration]:
|
|
43
|
+
"""Get list of available integrations.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
setting_type: Type of settings to list (USER or PROJECT)
|
|
47
|
+
page: Page number for pagination
|
|
48
|
+
per_page: Number of items per page
|
|
49
|
+
filters: Optional filters to apply
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
List of integrations matching the criteria
|
|
53
|
+
"""
|
|
54
|
+
params = PaginationParams(page=page, per_page=per_page).to_dict()
|
|
55
|
+
if filters:
|
|
56
|
+
params["filters"] = json.dumps(filters)
|
|
57
|
+
|
|
58
|
+
return self._api.get(
|
|
59
|
+
self._get_base_path(setting_type), List[Integration], params=params
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def get(
|
|
63
|
+
self, integration_id: str, setting_type: IntegrationType = IntegrationType.USER
|
|
64
|
+
) -> Integration:
|
|
65
|
+
"""Get integration by ID.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
integration_id: ID of the integration to retrieve
|
|
69
|
+
setting_type: Type of settings to get (USER or PROJECT)
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Integration details
|
|
73
|
+
|
|
74
|
+
Raises:
|
|
75
|
+
NotFoundError: If integration with given ID is not found
|
|
76
|
+
"""
|
|
77
|
+
integrations = self.list(setting_type=setting_type, per_page=100)
|
|
78
|
+
integration = next((i for i in integrations if i.id == integration_id), None)
|
|
79
|
+
if integration is None:
|
|
80
|
+
raise NotFoundError("Integration", integration_id)
|
|
81
|
+
|
|
82
|
+
return integration
|
|
83
|
+
|
|
84
|
+
def get_by_alias(
|
|
85
|
+
self, alias: str, setting_type: IntegrationType = IntegrationType.USER
|
|
86
|
+
) -> Optional[Integration]:
|
|
87
|
+
"""Get integration by its alias.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
alias: Alias of the integration to retrieve
|
|
91
|
+
setting_type: Type of settings to get (USER or PROJECT)
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Integration details if found, None otherwise
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
NotFoundError: If integration with given alias is not found
|
|
98
|
+
"""
|
|
99
|
+
integrations = self.list(setting_type=setting_type, per_page=100)
|
|
100
|
+
integration = next((i for i in integrations if i.alias == alias), None)
|
|
101
|
+
|
|
102
|
+
if integration is None:
|
|
103
|
+
raise NotFoundError("Integration", alias)
|
|
104
|
+
|
|
105
|
+
return integration
|
|
106
|
+
|
|
107
|
+
def create(self, settings: Integration) -> dict:
|
|
108
|
+
"""Create a new integration.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
settings: integration creation request
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Created integration details
|
|
115
|
+
"""
|
|
116
|
+
return self._api.post(
|
|
117
|
+
self._get_base_path(settings.setting_type),
|
|
118
|
+
dict,
|
|
119
|
+
json_data=settings.model_dump(exclude_none=True),
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def update(self, setting_id: str, settings: Integration) -> dict:
|
|
123
|
+
"""Update an existing integration.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
setting_id: ID of the integration to update
|
|
127
|
+
settings: integration update request
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Updated integration details
|
|
131
|
+
"""
|
|
132
|
+
return self._api.put(
|
|
133
|
+
f"{self._get_base_path(settings.setting_type)}/{setting_id}",
|
|
134
|
+
dict,
|
|
135
|
+
json_data=settings.model_dump(exclude_none=True),
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
def delete(
|
|
139
|
+
self, setting_id: str, setting_type: IntegrationType = IntegrationType.USER
|
|
140
|
+
) -> dict:
|
|
141
|
+
"""Delete an integration by ID.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
setting_id: ID of the integration to delete
|
|
145
|
+
setting_type: Type of settings to delete (USER or PROJECT)
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Deletion confirmation
|
|
149
|
+
"""
|
|
150
|
+
return self._api.delete(
|
|
151
|
+
f"{self._get_base_path(setting_type)}/{setting_id}", dict
|
|
152
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""LLM service implementation."""
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
from ..models.llm import LLMModel
|
|
6
|
+
from ..utils.http import ApiRequestHandler
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class LLMService:
|
|
10
|
+
"""Service for managing LLM models."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
13
|
+
"""Initialize the LLM models service.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
api_domain: Base URL for the CodeMie API
|
|
17
|
+
token: Authentication token
|
|
18
|
+
verify_ssl: Whether to verify SSL certificates. Default: True
|
|
19
|
+
"""
|
|
20
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
21
|
+
|
|
22
|
+
def list(self) -> List[LLMModel]:
|
|
23
|
+
"""Get list of available LLM models.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
List of LLM models
|
|
27
|
+
"""
|
|
28
|
+
return self._api.get("/v1/llm_models", List[LLMModel], wrap_response=False)
|
|
29
|
+
|
|
30
|
+
def list_embeddings(self) -> List[LLMModel]:
|
|
31
|
+
"""Get list of available embeddings models.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
List of embeddings models
|
|
35
|
+
"""
|
|
36
|
+
return self._api.get(
|
|
37
|
+
"/v1/embeddings_models", List[LLMModel], wrap_response=False
|
|
38
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Task service implementation."""
|
|
2
|
+
|
|
3
|
+
from ..models.task import BackgroundTaskEntity
|
|
4
|
+
from ..utils.http import ApiRequestHandler
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TaskService:
|
|
8
|
+
"""Service for managing background tasks."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
11
|
+
"""Initialize the Task service.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
api_domain: Base URL for the CodeMie API
|
|
15
|
+
token: Authentication token
|
|
16
|
+
verify_ssl: Whether to verify SSL certificates. Default: True
|
|
17
|
+
"""
|
|
18
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
19
|
+
|
|
20
|
+
def get(self, task_id: str) -> BackgroundTaskEntity:
|
|
21
|
+
"""Get a background task by ID.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
task_id: The ID of the task to retrieve
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
BackgroundTaskEntity: The task details
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
ApiError: If the task doesn't exist or there's an API error
|
|
31
|
+
"""
|
|
32
|
+
return self._api.get(
|
|
33
|
+
f"/v1/tasks/{task_id}", BackgroundTaskEntity, wrap_response=False
|
|
34
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""User service implementation."""
|
|
2
|
+
|
|
3
|
+
from ..models.user import User, UserData
|
|
4
|
+
from ..utils.http import ApiRequestHandler
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class UserService:
|
|
8
|
+
"""Service for managing user profile and preferences."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, api_domain: str, token: str, verify_ssl: bool = True):
|
|
11
|
+
"""Initialize the User service.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
api_domain: Base URL for the CodeMie API
|
|
15
|
+
token: Authentication token
|
|
16
|
+
verify_ssl: Whether to verify SSL certificates. Default: True
|
|
17
|
+
"""
|
|
18
|
+
self._api = ApiRequestHandler(api_domain, token, verify_ssl)
|
|
19
|
+
|
|
20
|
+
def about_me(self) -> User:
|
|
21
|
+
"""Get current user profile.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
User profile information
|
|
25
|
+
"""
|
|
26
|
+
return self._api.get("/v1/user", User, wrap_response=False)
|
|
27
|
+
|
|
28
|
+
def get_data(self) -> UserData:
|
|
29
|
+
"""Get user data and preferences.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
User data and preferences
|
|
33
|
+
"""
|
|
34
|
+
return self._api.get("/v1/user/data", UserData, wrap_response=False)
|