alita-sdk 0.3.346__py3-none-any.whl → 0.3.348__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 alita-sdk might be problematic. Click here for more details.
- alita_sdk/runtime/clients/artifact.py +11 -1
- alita_sdk/runtime/clients/client.py +8 -1
- alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py +117 -31
- alita_sdk/runtime/tools/artifact.py +1 -0
- alita_sdk/runtime/tools/vectorstore.py +1 -1
- alita_sdk/runtime/tools/vectorstore_base.py +1 -1
- alita_sdk/tools/figma/api_wrapper.py +1 -1
- alita_sdk/tools/testrail/api_wrapper.py +138 -55
- {alita_sdk-0.3.346.dist-info → alita_sdk-0.3.348.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.346.dist-info → alita_sdk-0.3.348.dist-info}/RECORD +13 -13
- {alita_sdk-0.3.346.dist-info → alita_sdk-0.3.348.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.346.dist-info → alita_sdk-0.3.348.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.346.dist-info → alita_sdk-0.3.348.dist-info}/top_level.txt +0 -0
|
@@ -42,7 +42,17 @@ class Artifact:
|
|
|
42
42
|
return f"{data['error']}. {data['content'] if data['content'] else ''}"
|
|
43
43
|
detected = chardet.detect(data)
|
|
44
44
|
if detected['encoding'] is not None:
|
|
45
|
-
|
|
45
|
+
try:
|
|
46
|
+
return data.decode(detected['encoding'])
|
|
47
|
+
except Exception:
|
|
48
|
+
logger.error("Error while default encoding")
|
|
49
|
+
return parse_file_content(file_name=artifact_name,
|
|
50
|
+
file_content=data,
|
|
51
|
+
is_capture_image=is_capture_image,
|
|
52
|
+
page_number=page_number,
|
|
53
|
+
sheet_name=sheet_name,
|
|
54
|
+
excel_by_sheets=excel_by_sheets,
|
|
55
|
+
llm=llm)
|
|
46
56
|
else:
|
|
47
57
|
return parse_file_content(file_name=artifact_name,
|
|
48
58
|
file_content=data,
|
|
@@ -69,6 +69,7 @@ class AlitaClient:
|
|
|
69
69
|
self.configurations_url = f'{self.base_url}{self.api_path}/integrations/integrations/default/{self.project_id}?section=configurations&unsecret=true'
|
|
70
70
|
self.ai_section_url = f'{self.base_url}{self.api_path}/integrations/integrations/default/{self.project_id}?section=ai'
|
|
71
71
|
self.configurations: list = configurations or []
|
|
72
|
+
self.model_timeout = kwargs.get('model_timeout', 120)
|
|
72
73
|
|
|
73
74
|
def get_mcp_toolkits(self):
|
|
74
75
|
if user_id := self._get_real_user_id():
|
|
@@ -85,7 +86,12 @@ class AlitaClient:
|
|
|
85
86
|
# This loop iterates over each key-value pair in the arguments dictionary,
|
|
86
87
|
# and if a value is a Pydantic object, it replaces it with its dictionary representation using .dict().
|
|
87
88
|
for arg_name, arg_value in params.get('params', {}).get('arguments', {}).items():
|
|
88
|
-
if
|
|
89
|
+
if isinstance(arg_value, list):
|
|
90
|
+
params['params']['arguments'][arg_name] = [
|
|
91
|
+
item.dict() if hasattr(item, "dict") and callable(item.dict) else item
|
|
92
|
+
for item in arg_value
|
|
93
|
+
]
|
|
94
|
+
elif hasattr(arg_value, "dict") and callable(arg_value.dict):
|
|
89
95
|
params['params']['arguments'][arg_name] = arg_value.dict()
|
|
90
96
|
#
|
|
91
97
|
response = requests.post(url, headers=self.headers, json=params, verify=False)
|
|
@@ -179,6 +185,7 @@ class AlitaClient:
|
|
|
179
185
|
model=embedding_model,
|
|
180
186
|
api_key=self.auth_token,
|
|
181
187
|
openai_organization=str(self.project_id),
|
|
188
|
+
request_timeout=self.model_timeout
|
|
182
189
|
)
|
|
183
190
|
|
|
184
191
|
def get_llm(self, model_name: str, model_config: dict) -> ChatOpenAI:
|
|
@@ -12,27 +12,32 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import io
|
|
15
|
+
import os
|
|
15
16
|
from typing import Iterator
|
|
16
17
|
import pandas as pd
|
|
17
18
|
from json import loads
|
|
18
19
|
|
|
19
20
|
from openpyxl import load_workbook
|
|
21
|
+
from xlrd import open_workbook
|
|
20
22
|
from langchain_core.documents import Document
|
|
21
23
|
from .AlitaTableLoader import AlitaTableLoader
|
|
22
|
-
|
|
23
|
-
cell_delimeter = " | "
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
cell_delimiter = " | "
|
|
26
26
|
|
|
27
|
+
class AlitaExcelLoader(AlitaTableLoader):
|
|
27
28
|
excel_by_sheets: bool = False
|
|
28
29
|
sheet_name: str = None
|
|
29
30
|
return_type: str = 'str'
|
|
31
|
+
file_name: str = None
|
|
30
32
|
|
|
31
33
|
def __init__(self, **kwargs):
|
|
32
34
|
if not kwargs.get('file_path'):
|
|
33
35
|
file_content = kwargs.get('file_content')
|
|
34
36
|
if file_content:
|
|
37
|
+
self.file_name = kwargs.get('file_name')
|
|
35
38
|
kwargs['file_path'] = io.BytesIO(file_content)
|
|
39
|
+
else:
|
|
40
|
+
self.file_name = kwargs.get('file_path')
|
|
36
41
|
super().__init__(**kwargs)
|
|
37
42
|
self.excel_by_sheets = kwargs.get('excel_by_sheets')
|
|
38
43
|
self.return_type = kwargs.get('return_type')
|
|
@@ -40,36 +45,82 @@ class AlitaExcelLoader(AlitaTableLoader):
|
|
|
40
45
|
|
|
41
46
|
def get_content(self):
|
|
42
47
|
try:
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
raise ValueError(f"Sheet '{self.sheet_name}' does not exist in the workbook.")
|
|
53
|
-
elif self.excel_by_sheets:
|
|
54
|
-
# Parse each sheet individually and return as a dictionary
|
|
55
|
-
result = {}
|
|
56
|
-
for sheet_name in workbook.sheetnames:
|
|
57
|
-
sheet_content = self.parse_sheet(workbook[sheet_name])
|
|
58
|
-
result[sheet_name] = sheet_content
|
|
59
|
-
return result
|
|
48
|
+
# Determine file extension
|
|
49
|
+
file_extension = os.path.splitext(self.file_name)[-1].lower()
|
|
50
|
+
|
|
51
|
+
if file_extension == '.xlsx':
|
|
52
|
+
# Use openpyxl for .xlsx files
|
|
53
|
+
return self._read_xlsx()
|
|
54
|
+
elif file_extension == '.xls':
|
|
55
|
+
# Use xlrd for .xls files
|
|
56
|
+
return self._read_xls()
|
|
60
57
|
else:
|
|
61
|
-
|
|
62
|
-
result = []
|
|
63
|
-
for sheet_name in workbook.sheetnames:
|
|
64
|
-
sheet_content = self.parse_sheet(workbook[sheet_name])
|
|
65
|
-
result.append(f"====== Sheet name: {sheet_name} ======\n{sheet_content}")
|
|
66
|
-
return "\n\n".join(result)
|
|
58
|
+
raise ValueError(f"Unsupported file format: {file_extension}")
|
|
67
59
|
except Exception as e:
|
|
68
60
|
return f"Error reading Excel file: {e}"
|
|
69
61
|
|
|
62
|
+
def _read_xlsx(self):
|
|
63
|
+
"""
|
|
64
|
+
Reads .xlsx files using openpyxl.
|
|
65
|
+
"""
|
|
66
|
+
workbook = load_workbook(self.file_path, data_only=True) # `data_only=True` ensures we get cell values, not formulas
|
|
67
|
+
|
|
68
|
+
if self.sheet_name:
|
|
69
|
+
# If a specific sheet name is provided, parse only that sheet
|
|
70
|
+
if self.sheet_name in workbook.sheetnames:
|
|
71
|
+
sheet_content = self.parse_sheet(workbook[self.sheet_name])
|
|
72
|
+
return sheet_content
|
|
73
|
+
else:
|
|
74
|
+
raise ValueError(f"Sheet '{self.sheet_name}' does not exist in the workbook.")
|
|
75
|
+
elif self.excel_by_sheets:
|
|
76
|
+
# Parse each sheet individually and return as a dictionary
|
|
77
|
+
result = {}
|
|
78
|
+
for sheet_name in workbook.sheetnames:
|
|
79
|
+
sheet_content = self.parse_sheet(workbook[sheet_name])
|
|
80
|
+
result[sheet_name] = sheet_content
|
|
81
|
+
return result
|
|
82
|
+
else:
|
|
83
|
+
# Combine all sheets into a single string result
|
|
84
|
+
result = []
|
|
85
|
+
for sheet_name in workbook.sheetnames:
|
|
86
|
+
sheet_content = self.parse_sheet(workbook[sheet_name])
|
|
87
|
+
result.append(f"====== Sheet name: {sheet_name} ======\n{sheet_content}")
|
|
88
|
+
return "\n\n".join(result)
|
|
89
|
+
|
|
90
|
+
def _read_xls(self):
|
|
91
|
+
"""
|
|
92
|
+
Reads .xls files using xlrd.
|
|
93
|
+
"""
|
|
94
|
+
workbook = open_workbook(filename=self.file_name, file_contents=self.file_content)
|
|
95
|
+
|
|
96
|
+
if self.sheet_name:
|
|
97
|
+
# If a specific sheet name is provided, parse only that sheet
|
|
98
|
+
if self.sheet_name in workbook.sheet_names():
|
|
99
|
+
sheet = workbook.sheet_by_name(self.sheet_name)
|
|
100
|
+
sheet_content = self.parse_sheet_xls(sheet)
|
|
101
|
+
return sheet_content
|
|
102
|
+
else:
|
|
103
|
+
raise ValueError(f"Sheet '{self.sheet_name}' does not exist in the workbook.")
|
|
104
|
+
elif self.excel_by_sheets:
|
|
105
|
+
# Parse each sheet individually and return as a dictionary
|
|
106
|
+
result = {}
|
|
107
|
+
for sheet_name in workbook.sheet_names():
|
|
108
|
+
sheet = workbook.sheet_by_name(sheet_name)
|
|
109
|
+
sheet_content = self.parse_sheet_xls(sheet)
|
|
110
|
+
result[sheet_name] = sheet_content
|
|
111
|
+
return result
|
|
112
|
+
else:
|
|
113
|
+
# Combine all sheets into a single string result
|
|
114
|
+
result = []
|
|
115
|
+
for sheet_name in workbook.sheet_names():
|
|
116
|
+
sheet = workbook.sheet_by_name(sheet_name)
|
|
117
|
+
sheet_content = self.parse_sheet_xls(sheet)
|
|
118
|
+
result.append(f"====== Sheet name: {sheet_name} ======\n{sheet_content}")
|
|
119
|
+
return "\n\n".join(result)
|
|
120
|
+
|
|
70
121
|
def parse_sheet(self, sheet):
|
|
71
122
|
"""
|
|
72
|
-
Parses a single sheet, extracting text and hyperlinks, and formats them.
|
|
123
|
+
Parses a single .xlsx sheet, extracting text and hyperlinks, and formats them.
|
|
73
124
|
"""
|
|
74
125
|
sheet_content = []
|
|
75
126
|
|
|
@@ -85,17 +136,52 @@ class AlitaExcelLoader(AlitaTableLoader):
|
|
|
85
136
|
# If no hyperlink, use the cell value (computed value if formula)
|
|
86
137
|
row_content.append(str(cell.value) if cell.value is not None else "")
|
|
87
138
|
# Join the row content into a single line using `|` as the delimiter
|
|
88
|
-
sheet_content.append(
|
|
139
|
+
sheet_content.append(cell_delimiter.join(row_content))
|
|
140
|
+
|
|
141
|
+
# Format the sheet content based on the return type
|
|
142
|
+
return self._format_sheet_content(sheet_content)
|
|
143
|
+
|
|
144
|
+
def parse_sheet_xls(self, sheet):
|
|
145
|
+
"""
|
|
146
|
+
Parses a single .xls sheet using xlrd, extracting text and hyperlinks, and formats them.
|
|
147
|
+
"""
|
|
148
|
+
sheet_content = []
|
|
149
|
+
|
|
150
|
+
# Extract hyperlink map (if available)
|
|
151
|
+
hyperlink_map = getattr(sheet, 'hyperlink_map', {})
|
|
152
|
+
|
|
153
|
+
for row_idx in range(sheet.nrows):
|
|
154
|
+
row_content = []
|
|
155
|
+
for col_idx in range(sheet.ncols):
|
|
156
|
+
cell = sheet.cell(row_idx, col_idx)
|
|
157
|
+
cell_value = cell.value
|
|
158
|
+
|
|
159
|
+
# Check if the cell has a hyperlink
|
|
160
|
+
cell_address = (row_idx, col_idx)
|
|
161
|
+
if cell_address in hyperlink_map:
|
|
162
|
+
hyperlink = hyperlink_map[cell_address].url_or_path
|
|
163
|
+
if cell_value:
|
|
164
|
+
row_content.append(f"[{cell_value}]({hyperlink})")
|
|
165
|
+
else:
|
|
166
|
+
row_content.append(str(cell_value) if cell_value is not None else "")
|
|
167
|
+
# Join the row content into a single line using `|` as the delimiter
|
|
168
|
+
sheet_content.append(cell_delimiter.join(row_content))
|
|
89
169
|
|
|
90
170
|
# Format the sheet content based on the return type
|
|
171
|
+
return self._format_sheet_content(sheet_content)
|
|
172
|
+
|
|
173
|
+
def _format_sheet_content(self, sheet_content):
|
|
174
|
+
"""
|
|
175
|
+
Formats the sheet content based on the return type.
|
|
176
|
+
"""
|
|
91
177
|
if self.return_type == 'dict':
|
|
92
178
|
# Convert to a list of dictionaries (each row is a dictionary)
|
|
93
|
-
headers = sheet_content[0].split(
|
|
179
|
+
headers = sheet_content[0].split(cell_delimiter) if sheet_content else []
|
|
94
180
|
data_rows = sheet_content[1:] if len(sheet_content) > 1 else []
|
|
95
|
-
return [dict(zip(headers, row.split(
|
|
181
|
+
return [dict(zip(headers, row.split(cell_delimiter))) for row in data_rows]
|
|
96
182
|
elif self.return_type == 'csv':
|
|
97
183
|
# Return as CSV (newline-separated rows, comma-separated values)
|
|
98
|
-
return "\n".join([",".join(row.split(
|
|
184
|
+
return "\n".join([",".join(row.split(cell_delimiter)) for row in sheet_content])
|
|
99
185
|
else:
|
|
100
186
|
# Default: Return as plain text (newline-separated rows, pipe-separated values)
|
|
101
187
|
return "\n".join(sheet_content)
|
|
@@ -71,6 +71,7 @@ class ArtifactWrapper(NonCodeIndexerToolkit):
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
def _base_loader(self, **kwargs) -> Generator[Document, None, None]:
|
|
74
|
+
self._log_tool_event(message=f"Loading the files from artifact's bucket. {kwargs=}", tool_name="loader")
|
|
74
75
|
try:
|
|
75
76
|
all_files = self.list_files(self.bucket, False)['rows']
|
|
76
77
|
except Exception as e:
|
|
@@ -137,7 +137,7 @@ class VectorStoreWrapper(BaseToolApiWrapper):
|
|
|
137
137
|
embedding_model_params: dict
|
|
138
138
|
vectorstore_type: str
|
|
139
139
|
vectorstore_params: dict
|
|
140
|
-
max_docs_per_add: int =
|
|
140
|
+
max_docs_per_add: int = 20
|
|
141
141
|
dataset: str = None
|
|
142
142
|
embedding: Any = None
|
|
143
143
|
vectorstore: Any = None
|
|
@@ -135,7 +135,7 @@ class VectorStoreWrapperBase(BaseToolApiWrapper):
|
|
|
135
135
|
embedding_model: Optional[str] = None
|
|
136
136
|
vectorstore_type: Optional[str] = None
|
|
137
137
|
vectorstore_params: Optional[dict] = None
|
|
138
|
-
max_docs_per_add: int =
|
|
138
|
+
max_docs_per_add: int = 20
|
|
139
139
|
dataset: Optional[str] = None
|
|
140
140
|
vectorstore: Any = None
|
|
141
141
|
pg_helper: Any = None
|
|
@@ -22,7 +22,7 @@ GLOBAL_REMOVE = []
|
|
|
22
22
|
GLOBAL_DEPTH_START = 4
|
|
23
23
|
GLOBAL_DEPTH_END = 6
|
|
24
24
|
EXTRA_PARAMS = (
|
|
25
|
-
Optional[Dict[str, Union[str, int, None]]],
|
|
25
|
+
Optional[Dict[str, Union[str, int, List, None]]],
|
|
26
26
|
Field(
|
|
27
27
|
description=(
|
|
28
28
|
"Additional parameters for customizing response processing:\n"
|
|
@@ -298,6 +298,18 @@ updateCase = create_model(
|
|
|
298
298
|
),
|
|
299
299
|
)
|
|
300
300
|
|
|
301
|
+
getSuites = create_model(
|
|
302
|
+
"getSuites",
|
|
303
|
+
project_id=(str, Field(description="Project id")),
|
|
304
|
+
output_format=(
|
|
305
|
+
str,
|
|
306
|
+
Field(
|
|
307
|
+
default="json",
|
|
308
|
+
description="Desired output format. Supported values: 'json', 'csv', 'markdown'. Defaults to 'json'.",
|
|
309
|
+
),
|
|
310
|
+
),
|
|
311
|
+
)
|
|
312
|
+
|
|
301
313
|
SUPPORTED_KEYS = {
|
|
302
314
|
"id", "title", "section_id", "template_id", "type_id", "priority_id", "milestone_id",
|
|
303
315
|
"refs", "created_by", "created_on", "updated_by", "updated_on", "estimate",
|
|
@@ -330,29 +342,74 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
330
342
|
cls._client = TestRailAPI(url, email, password)
|
|
331
343
|
return super().validate_toolkit(values)
|
|
332
344
|
|
|
333
|
-
def
|
|
345
|
+
def _is_suite_id_required(self, project_id: str) -> bool:
|
|
334
346
|
"""
|
|
335
|
-
|
|
336
|
-
|
|
347
|
+
Returns True if project requires suite_id (multiple suite or baselines mode), otherwise False.
|
|
337
348
|
Args:
|
|
338
349
|
project_id: The TestRail project ID to check
|
|
339
|
-
suite_id: The suite ID if provided (optional)
|
|
340
|
-
custom_error_msg: Custom error message to use (optional)
|
|
341
|
-
|
|
342
|
-
Raises:
|
|
343
|
-
ToolException: If project is in multiple suite mode and no suite_id is provided
|
|
344
350
|
"""
|
|
345
|
-
if suite_id:
|
|
346
|
-
return # No validation needed if suite_id is already provided
|
|
347
|
-
|
|
348
351
|
try:
|
|
349
352
|
project = self._client.projects.get_project(project_id=project_id)
|
|
350
353
|
# 1 for single suite mode, 2 for single suite + baselines, 3 for multiple suites
|
|
351
354
|
suite_mode = project.get('suite_mode', 1)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
return suite_mode == 2 or suite_mode == 3
|
|
356
|
+
except StatusCodeError:
|
|
357
|
+
return False
|
|
358
|
+
|
|
359
|
+
def _fetch_cases_with_suite_handling(
|
|
360
|
+
self,
|
|
361
|
+
project_id: str,
|
|
362
|
+
suite_id: Optional[str] = None,
|
|
363
|
+
**api_params
|
|
364
|
+
) -> List[Dict]:
|
|
365
|
+
"""
|
|
366
|
+
Unified method to fetch test cases with proper TestRail suite mode handling.
|
|
367
|
+
|
|
368
|
+
Args:
|
|
369
|
+
project_id: The TestRail project ID
|
|
370
|
+
suite_id: Optional suite ID to filter by
|
|
371
|
+
**api_params: Additional parameters to pass to the get_cases API call
|
|
372
|
+
|
|
373
|
+
Returns:
|
|
374
|
+
List of test case dictionaries
|
|
375
|
+
"""
|
|
376
|
+
def _extract_cases_from_response(response):
|
|
377
|
+
"""Extract cases from API response, supporting both old and new testrail_api versions."""
|
|
378
|
+
return response.get('cases', []) if isinstance(response, dict) else response
|
|
379
|
+
|
|
380
|
+
suite_required = self._is_suite_id_required(project_id=project_id)
|
|
381
|
+
all_cases = []
|
|
382
|
+
|
|
383
|
+
if suite_required:
|
|
384
|
+
# Suite modes 2 & 3: Require suite_id parameter
|
|
385
|
+
if suite_id:
|
|
386
|
+
response = self._client.cases.get_cases(
|
|
387
|
+
project_id=project_id, suite_id=int(suite_id), **api_params
|
|
388
|
+
)
|
|
389
|
+
cases_from_suite = _extract_cases_from_response(response)
|
|
390
|
+
all_cases.extend(cases_from_suite)
|
|
391
|
+
else:
|
|
392
|
+
suites = self._get_raw_suites(project_id)
|
|
393
|
+
suite_ids = [suite['id'] for suite in suites if 'id' in suite]
|
|
394
|
+
for current_suite_id in suite_ids:
|
|
395
|
+
try:
|
|
396
|
+
response = self._client.cases.get_cases(
|
|
397
|
+
project_id=project_id, suite_id=int(current_suite_id), **api_params
|
|
398
|
+
)
|
|
399
|
+
cases_from_suite = _extract_cases_from_response(response)
|
|
400
|
+
all_cases.extend(cases_from_suite)
|
|
401
|
+
except StatusCodeError:
|
|
402
|
+
continue
|
|
403
|
+
else:
|
|
404
|
+
# Suite mode 1: Can fetch all cases directly without suite_id
|
|
405
|
+
try:
|
|
406
|
+
response = self._client.cases.get_cases(project_id=project_id, **api_params)
|
|
407
|
+
cases_from_project = _extract_cases_from_response(response)
|
|
408
|
+
all_cases.extend(cases_from_project)
|
|
409
|
+
except StatusCodeError as e:
|
|
410
|
+
logger.warning(f"Unable to fetch cases at project level: {e}")
|
|
411
|
+
|
|
412
|
+
return all_cases
|
|
356
413
|
|
|
357
414
|
def add_cases(self, add_test_cases_data: str):
|
|
358
415
|
"""Adds new test cases into Testrail per defined parameters.
|
|
@@ -442,17 +499,10 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
442
499
|
invalid_keys = [key for key in keys if key not in SUPPORTED_KEYS]
|
|
443
500
|
|
|
444
501
|
try:
|
|
445
|
-
#
|
|
446
|
-
self.
|
|
447
|
-
project_id=project_id,
|
|
448
|
-
suite_id=suite_id
|
|
449
|
-
)
|
|
450
|
-
|
|
451
|
-
extracted_cases = self._client.cases.get_cases(project_id=project_id, suite_id=suite_id)
|
|
452
|
-
# support old versions of testrail_api
|
|
453
|
-
cases = extracted_cases.get("cases") if isinstance(extracted_cases, dict) else extracted_cases
|
|
502
|
+
# Use unified suite handling method
|
|
503
|
+
cases = self._fetch_cases_with_suite_handling(project_id=project_id, suite_id=suite_id)
|
|
454
504
|
|
|
455
|
-
if cases
|
|
505
|
+
if not cases:
|
|
456
506
|
return ToolException("No test cases found in the extracted data.")
|
|
457
507
|
|
|
458
508
|
extracted_cases_data = [
|
|
@@ -506,31 +556,35 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
506
556
|
)
|
|
507
557
|
self._log_tool_event(message=f"Extract test cases per filter {params}", tool_name='get_cases_by_filter')
|
|
508
558
|
|
|
509
|
-
#
|
|
510
|
-
suite_id_in_params = params.
|
|
511
|
-
|
|
512
|
-
project_id=project_id,
|
|
513
|
-
suite_id=str(suite_id_in_params) if suite_id_in_params else None
|
|
514
|
-
)
|
|
559
|
+
# Extract suite_id from params for unified handling
|
|
560
|
+
suite_id_in_params = params.pop('suite_id', None)
|
|
561
|
+
suite_id = str(suite_id_in_params) if suite_id_in_params else None
|
|
515
562
|
|
|
516
|
-
|
|
517
|
-
|
|
563
|
+
# Use unified suite handling method with remaining filter parameters
|
|
564
|
+
cases = self._fetch_cases_with_suite_handling(
|
|
565
|
+
project_id=project_id,
|
|
566
|
+
suite_id=suite_id,
|
|
567
|
+
**params
|
|
518
568
|
)
|
|
569
|
+
|
|
519
570
|
self._log_tool_event(message="Test cases were extracted", tool_name='get_cases_by_filter')
|
|
520
|
-
# support old versions of testrail_api
|
|
521
|
-
cases = extracted_cases.get("cases") if isinstance(extracted_cases, dict) else extracted_cases
|
|
522
571
|
|
|
523
|
-
if cases
|
|
572
|
+
if not cases:
|
|
524
573
|
return ToolException("No test cases found in the extracted data.")
|
|
525
574
|
|
|
526
575
|
if keys is None:
|
|
527
576
|
return self._to_markup(cases, output_format)
|
|
528
577
|
|
|
529
|
-
extracted_cases_data = [
|
|
530
|
-
|
|
531
|
-
|
|
578
|
+
extracted_cases_data = []
|
|
579
|
+
for case in cases:
|
|
580
|
+
case_dict = {}
|
|
581
|
+
for key in keys:
|
|
582
|
+
if key in case:
|
|
583
|
+
case_dict[key] = case[key]
|
|
584
|
+
if case_dict:
|
|
585
|
+
extracted_cases_data.append(case_dict)
|
|
532
586
|
|
|
533
|
-
if extracted_cases_data
|
|
587
|
+
if not extracted_cases_data:
|
|
534
588
|
return ToolException("No valid test case data found to format.")
|
|
535
589
|
|
|
536
590
|
result = self._to_markup(extracted_cases_data, output_format)
|
|
@@ -578,6 +632,40 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
578
632
|
return (
|
|
579
633
|
f"Test case #{case_id} has been updated at '{updated_case['updated_on']}')"
|
|
580
634
|
)
|
|
635
|
+
|
|
636
|
+
def _get_raw_suites(self, project_id: str) -> List[Dict]:
|
|
637
|
+
"""
|
|
638
|
+
Internal helper to get raw suite data from TestRail API.
|
|
639
|
+
Handles both old and new testrail_api response formats.
|
|
640
|
+
"""
|
|
641
|
+
suites_response = self._client.suites.get_suites(project_id=project_id)
|
|
642
|
+
if isinstance(suites_response, dict) and 'suites' in suites_response:
|
|
643
|
+
return suites_response['suites']
|
|
644
|
+
else:
|
|
645
|
+
return suites_response if isinstance(suites_response, list) else []
|
|
646
|
+
|
|
647
|
+
def get_suites(self, project_id: str, output_format: str = "json",) -> Union[str, ToolException]:
|
|
648
|
+
"""Extracts a list of test suites for a given project from Testrail"""
|
|
649
|
+
try:
|
|
650
|
+
suites = self._get_raw_suites(project_id)
|
|
651
|
+
|
|
652
|
+
if not suites:
|
|
653
|
+
return ToolException("No test suites found for the specified project.")
|
|
654
|
+
|
|
655
|
+
suite_dicts = []
|
|
656
|
+
for suite in suites:
|
|
657
|
+
if isinstance(suite, dict):
|
|
658
|
+
suite_dict = {}
|
|
659
|
+
for field in ["id", "name", "description", "project_id", "is_baseline",
|
|
660
|
+
"completed_on", "url", "is_master", "is_completed"]:
|
|
661
|
+
if field in suite:
|
|
662
|
+
suite_dict[field] = suite[field]
|
|
663
|
+
suite_dicts.append(suite_dict)
|
|
664
|
+
else:
|
|
665
|
+
suite_dicts.append({"suite": str(suite)})
|
|
666
|
+
return self._to_markup(suite_dicts, output_format)
|
|
667
|
+
except StatusCodeError as e:
|
|
668
|
+
return ToolException(f"Unable to extract test suites: {e}")
|
|
581
669
|
|
|
582
670
|
def _base_loader(self, project_id: str,
|
|
583
671
|
suite_id: Optional[str] = None,
|
|
@@ -589,24 +677,13 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
589
677
|
self._include_attachments = kwargs.get('include_attachments', False)
|
|
590
678
|
self._skip_attachment_extensions = kwargs.get('skip_attachment_extensions', [])
|
|
591
679
|
|
|
592
|
-
def _extract_cases_from_response(response):
|
|
593
|
-
"""Extract cases from API response, supporting both old and new testrail_api versions."""
|
|
594
|
-
return response.get('cases', []) if isinstance(response, dict) else response
|
|
595
|
-
|
|
596
680
|
try:
|
|
597
|
-
#
|
|
598
|
-
self.
|
|
599
|
-
|
|
600
|
-
if suite_id:
|
|
601
|
-
resp = self._client.cases.get_cases(project_id=project_id, suite_id=int(suite_id))
|
|
602
|
-
else:
|
|
603
|
-
resp = self._client.cases.get_cases(project_id=project_id)
|
|
604
|
-
|
|
605
|
-
cases = _extract_cases_from_response(resp)
|
|
606
|
-
|
|
681
|
+
# Use unified suite handling method
|
|
682
|
+
cases = self._fetch_cases_with_suite_handling(project_id=project_id, suite_id=suite_id)
|
|
607
683
|
except StatusCodeError as e:
|
|
608
684
|
raise ToolException(f"Unable to extract test cases: {e}")
|
|
609
|
-
|
|
685
|
+
|
|
686
|
+
# Apply filters
|
|
610
687
|
if section_id is not None:
|
|
611
688
|
cases = [case for case in cases if case.get('section_id') == section_id]
|
|
612
689
|
if title_keyword is not None:
|
|
@@ -810,6 +887,12 @@ class TestrailAPIWrapper(NonCodeIndexerToolkit):
|
|
|
810
887
|
"ref": self.update_case,
|
|
811
888
|
"description": self.update_case.__doc__,
|
|
812
889
|
"args_schema": updateCase,
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
"name": "get_suites",
|
|
893
|
+
"ref": self.get_suites,
|
|
894
|
+
"description": self.get_suites.__doc__,
|
|
895
|
+
"args_schema": getSuites,
|
|
813
896
|
}
|
|
814
897
|
]
|
|
815
898
|
return tools
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: alita_sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.348
|
|
4
4
|
Summary: SDK for building langchain agents using resources from Alita
|
|
5
5
|
Author-email: Artem Rozumenko <artyom.rozumenko@gmail.com>, Mikalai Biazruchka <mikalai_biazruchka@epam.com>, Roman Mitusov <roman_mitusov@epam.com>, Ivan Krakhmaliuk <lifedj27@gmail.com>, Artem Dubrovskiy <ad13box@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -35,8 +35,8 @@ alita_sdk/configurations/zephyr_enterprise.py,sha256=UaBk3qWcT2-bCzko5HEPvgxArw1
|
|
|
35
35
|
alita_sdk/configurations/zephyr_essential.py,sha256=tUIrh-PRNvdrLBj6rJXqlF-h6oaMXUQI1wgit07kFBw,752
|
|
36
36
|
alita_sdk/runtime/__init__.py,sha256=4W0UF-nl3QF2bvET5lnah4o24CoTwSoKXhuN0YnwvEE,828
|
|
37
37
|
alita_sdk/runtime/clients/__init__.py,sha256=BdehU5GBztN1Qi1Wul0cqlU46FxUfMnI6Vq2Zd_oq1M,296
|
|
38
|
-
alita_sdk/runtime/clients/artifact.py,sha256=
|
|
39
|
-
alita_sdk/runtime/clients/client.py,sha256=
|
|
38
|
+
alita_sdk/runtime/clients/artifact.py,sha256=Tt3aWcxu20bVW6EX7s_iX5CTmcItKhUnkk8Q2gv2vw0,4036
|
|
39
|
+
alita_sdk/runtime/clients/client.py,sha256=T3hmVnT63iLWEGeuJb8k8Httw-sSWUpy6rsrumD0P0w,43699
|
|
40
40
|
alita_sdk/runtime/clients/datasource.py,sha256=HAZovoQN9jBg0_-lIlGBQzb4FJdczPhkHehAiVG3Wx0,1020
|
|
41
41
|
alita_sdk/runtime/clients/prompt.py,sha256=li1RG9eBwgNK_Qf0qUaZ8QNTmsncFrAL2pv3kbxZRZg,1447
|
|
42
42
|
alita_sdk/runtime/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -56,7 +56,7 @@ alita_sdk/runtime/langchain/document_loaders/AlitaCSVLoader.py,sha256=3ne-a5qIkB
|
|
|
56
56
|
alita_sdk/runtime/langchain/document_loaders/AlitaConfluenceLoader.py,sha256=NzpoL4C7UzyzLouTSL_xTQw70MitNt-WZz3Eyl7QkTA,8294
|
|
57
57
|
alita_sdk/runtime/langchain/document_loaders/AlitaDirectoryLoader.py,sha256=fKezkgvIcLG7S2PVJp1a8sZd6C4XQKNZKAFC87DbQts,7003
|
|
58
58
|
alita_sdk/runtime/langchain/document_loaders/AlitaDocxMammothLoader.py,sha256=9hi5eHgDIfa9wBWqTuwMM6D6W64czrDTfZl_htooe8Y,5943
|
|
59
|
-
alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py,sha256=
|
|
59
|
+
alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py,sha256=h8x1Xma_IBM4NdGXVVuvHHSlFQgY0S7Xjj8oGZhdFL8,9256
|
|
60
60
|
alita_sdk/runtime/langchain/document_loaders/AlitaGitRepoLoader.py,sha256=5WXGcyHraSVj3ANHj_U6X4EDikoekrIYtS0Q_QqNIng,2608
|
|
61
61
|
alita_sdk/runtime/langchain/document_loaders/AlitaImageLoader.py,sha256=QwgBJE-BvOasjgT1hYHZc0MP0F_elirUjSzKixoM6fY,6610
|
|
62
62
|
alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py,sha256=Nav2cgCQKOHQi_ZgYYn_iFdP_Os56KVlVR5nHGXecBc,3445
|
|
@@ -106,7 +106,7 @@ alita_sdk/runtime/toolkits/vectorstore.py,sha256=BGppQADa1ZiLO17fC0uCACTTEvPHlod
|
|
|
106
106
|
alita_sdk/runtime/tools/__init__.py,sha256=7OA8YPKlEOfXu3-gJA08cyR-VymjSPL-OmbXI-B2xVA,355
|
|
107
107
|
alita_sdk/runtime/tools/agent.py,sha256=m98QxOHwnCRTT9j18Olbb5UPS8-ZGeQaGiUyZJSyFck,3162
|
|
108
108
|
alita_sdk/runtime/tools/application.py,sha256=z3vLZODs-_xEEnZFmGF0fKz1j3VtNJxqsAmg5ovExpQ,3129
|
|
109
|
-
alita_sdk/runtime/tools/artifact.py,sha256=
|
|
109
|
+
alita_sdk/runtime/tools/artifact.py,sha256=4xA_va11WxO0fQclavKivRo24GI1b5qpsp2YZt7RxGY,10795
|
|
110
110
|
alita_sdk/runtime/tools/datasource.py,sha256=pvbaSfI-ThQQnjHG-QhYNSTYRnZB0rYtZFpjCfpzxYI,2443
|
|
111
111
|
alita_sdk/runtime/tools/echo.py,sha256=spw9eCweXzixJqHnZofHE1yWiSUa04L4VKycf3KCEaM,486
|
|
112
112
|
alita_sdk/runtime/tools/function.py,sha256=0iZJ-UxaPbtcXAVX9G5Vsn7vmD7lrz3cBG1qylto1gs,2844
|
|
@@ -121,8 +121,8 @@ alita_sdk/runtime/tools/prompt.py,sha256=nJafb_e5aOM1Rr3qGFCR-SKziU9uCsiP2okIMs9
|
|
|
121
121
|
alita_sdk/runtime/tools/router.py,sha256=wCvZjVkdXK9dMMeEerrgKf5M790RudH68pDortnHSz0,1517
|
|
122
122
|
alita_sdk/runtime/tools/sandbox.py,sha256=WNz-aUMtkGCPg84dDy_0BPkyp-6YjoYB-xjIEFFrtKw,11601
|
|
123
123
|
alita_sdk/runtime/tools/tool.py,sha256=lE1hGi6qOAXG7qxtqxarD_XMQqTghdywf261DZawwno,5631
|
|
124
|
-
alita_sdk/runtime/tools/vectorstore.py,sha256=
|
|
125
|
-
alita_sdk/runtime/tools/vectorstore_base.py,sha256=
|
|
124
|
+
alita_sdk/runtime/tools/vectorstore.py,sha256=8vRhi1lGFEs3unvnflEi2p59U2MfV32lStpEizpDms0,34467
|
|
125
|
+
alita_sdk/runtime/tools/vectorstore_base.py,sha256=7ZkbegFG0XTQBYGsJjtrkK-zrqKwketfx8vSJzuPCug,27292
|
|
126
126
|
alita_sdk/runtime/utils/AlitaCallback.py,sha256=E4LlSBuCHWiUq6W7IZExERHZY0qcmdjzc_rJlF2iQIw,7356
|
|
127
127
|
alita_sdk/runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
128
128
|
alita_sdk/runtime/utils/constants.py,sha256=Xntx1b_uxUzT4clwqHA_U6K8y5bBqf_4lSQwXdcWrp4,13586
|
|
@@ -236,7 +236,7 @@ alita_sdk/tools/custom_open_api/api_wrapper.py,sha256=sDSFpvEqpSvXHGiBISdQQcUecf
|
|
|
236
236
|
alita_sdk/tools/elastic/__init__.py,sha256=iwnSRppRpzvJ1da2K3Glu8Uu41MhBDCYbguboLkEbW0,2818
|
|
237
237
|
alita_sdk/tools/elastic/api_wrapper.py,sha256=pl8CqQxteJAGwyOhMcld-ZgtOTFwwbv42OITQVe8rM0,1948
|
|
238
238
|
alita_sdk/tools/figma/__init__.py,sha256=W6vIMMkZI2Lmpg6_CRRV3oadaIbVI-qTLmKUh6enqWs,4509
|
|
239
|
-
alita_sdk/tools/figma/api_wrapper.py,sha256=
|
|
239
|
+
alita_sdk/tools/figma/api_wrapper.py,sha256=yK45guP6oMStTpfNLXRYgIZtNWkuWzgjFm_Vzu-ivNg,33687
|
|
240
240
|
alita_sdk/tools/github/__init__.py,sha256=2rHu0zZyZGnLC5CkHgDIhe14N9yCyaEfrrt7ydH8478,5191
|
|
241
241
|
alita_sdk/tools/github/api_wrapper.py,sha256=uDwYckdnpYRJtb0uZnDkaz2udvdDLVxuCh1tSwspsiU,8411
|
|
242
242
|
alita_sdk/tools/github/github_client.py,sha256=0YkpD6Zm4X46jMNN57ZIypo2YObtgxCGQokJAF-laFs,86597
|
|
@@ -325,7 +325,7 @@ alita_sdk/tools/sql/models.py,sha256=AKJgSl_kEEz4fZfw3kbvdGHXaRZ-yiaqfJOB6YOj3i0
|
|
|
325
325
|
alita_sdk/tools/testio/__init__.py,sha256=NEvQtzsffqAXryaffVk0GpdcxZQ1AMkfeztnxHwNql4,2798
|
|
326
326
|
alita_sdk/tools/testio/api_wrapper.py,sha256=BvmL5h634BzG6p7ajnQLmj-uoAw1gjWnd4FHHu1h--Q,21638
|
|
327
327
|
alita_sdk/tools/testrail/__init__.py,sha256=Xg4nVjULL_D8JpIXLYXppnwUfGF4-lguFwKHmP5VwxM,4696
|
|
328
|
-
alita_sdk/tools/testrail/api_wrapper.py,sha256=
|
|
328
|
+
alita_sdk/tools/testrail/api_wrapper.py,sha256=tQcGlFJmftvs5ZiO4tsP19fCo4CrJeq_UEvQR1liVfE,39891
|
|
329
329
|
alita_sdk/tools/utils/__init__.py,sha256=W9rCCUPtHCP5nGAbWp0n5jaNA84572aiRoqKneBnaS4,3330
|
|
330
330
|
alita_sdk/tools/utils/available_tools_decorator.py,sha256=IbrdfeQkswxUFgvvN7-dyLMZMyXLiwvX7kgi3phciCk,273
|
|
331
331
|
alita_sdk/tools/utils/content_parser.py,sha256=q0wj__flyFlmzwlvbzAj3wCdHhLXysFbpcpCtrNfsGg,14437
|
|
@@ -350,8 +350,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=kT0TbmMvuKhDUZc0i7KO18O38JM9S
|
|
|
350
350
|
alita_sdk/tools/zephyr_squad/__init__.py,sha256=0ne8XLJEQSLOWfzd2HdnqOYmQlUliKHbBED5kW_Vias,2895
|
|
351
351
|
alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=kmw_xol8YIYFplBLWTqP_VKPRhL_1ItDD0_vXTe_UuI,14906
|
|
352
352
|
alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=R371waHsms4sllHCbijKYs90C-9Yu0sSR3N4SUfQOgU,5066
|
|
353
|
-
alita_sdk-0.3.
|
|
354
|
-
alita_sdk-0.3.
|
|
355
|
-
alita_sdk-0.3.
|
|
356
|
-
alita_sdk-0.3.
|
|
357
|
-
alita_sdk-0.3.
|
|
353
|
+
alita_sdk-0.3.348.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
354
|
+
alita_sdk-0.3.348.dist-info/METADATA,sha256=_oiAJpxGjG23s01B-P41PkJqG1oUgdAgS7QUnlyS5gc,19015
|
|
355
|
+
alita_sdk-0.3.348.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
356
|
+
alita_sdk-0.3.348.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
|
|
357
|
+
alita_sdk-0.3.348.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|