alita-sdk 0.3.361__py3-none-any.whl → 0.3.363__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.

@@ -165,7 +165,7 @@ def _mcp_tools(tools_list, alita):
165
165
  if not selected_tools or tool_name in selected_tools:
166
166
  if server_tool := _init_single_mcp_tool(server_toolkit_name,
167
167
  # selected_toolkit["name"] is None for toolkit_test
168
- selected_toolkit["name"] if selected_toolkit.get("name")
168
+ selected_toolkit["toolkit_name"] if selected_toolkit.get("toolkit_name")
169
169
  else server_toolkit_name,
170
170
  available_tool, alita, selected_toolkit['settings']):
171
171
  tools.append(server_tool)
@@ -1,13 +1,13 @@
1
1
  # api_wrapper.py
2
- from typing import Any, Dict, List, Optional
3
2
  import fnmatch
3
+ from typing import Any, Dict, List, Optional
4
4
 
5
5
  from langchain_core.tools import ToolException
6
-
7
- from ..code_indexer_toolkit import CodeIndexerToolkit
8
6
  from pydantic import create_model, Field, model_validator, SecretStr, PrivateAttr
9
7
 
8
+ from ..code_indexer_toolkit import CodeIndexerToolkit
10
9
  from ..utils.available_tools_decorator import extend_with_parent_available_tools
10
+ from ..utils.content_parser import parse_file_content
11
11
 
12
12
  AppendFileModel = create_model(
13
13
  "AppendFileModel",
@@ -318,7 +318,9 @@ class GitLabAPIWrapper(CodeIndexerToolkit):
318
318
  def read_file(self, file_path: str, branch: str) -> str:
319
319
  self.set_active_branch(branch)
320
320
  file = self.repo_instance.files.get(file_path, branch)
321
- return file.decode().decode("utf-8")
321
+ return parse_file_content(file_name=file_path,
322
+ file_content=file.decode(),
323
+ llm=self.llm)
322
324
 
323
325
  def update_file(self, file_query: str, branch: str) -> str:
324
326
  if branch == self.branch:
@@ -754,18 +754,15 @@ class JiraApiWrapper(NonCodeIndexerToolkit):
754
754
  logger.info(f"Skipping attachment {attachment['filename']} as it does not match pattern {attachment_pattern}")
755
755
  continue
756
756
  logger.info(f"Processing attachment {attachment['filename']} with ID {attachment['attachment_id']}")
757
- if self.api_version == "3":
758
- attachment_data.append(self._client.get_attachment_content(attachment['attachment_id']))
759
- else:
760
- try:
761
- attachment_content = self._client.get_attachment_content(attachment['attachment_id'])
762
- except Exception as e:
763
- logger.error(
764
- f"Failed to download attachment {attachment['filename']} for issue {jira_issue_key}: {str(e)}")
765
- attachment_content = self._client.get(
766
- path=f"secure/attachment/{attachment['attachment_id']}/{attachment['filename']}", not_json_response=True)
767
- content_docs = process_content_by_type(attachment_content, attachment['filename'], llm=self.llm)
768
- attachment_data.append("filename: " + attachment['filename'] + "\ncontent: " + str([doc.page_content for doc in content_docs]))
757
+ try:
758
+ attachment_content = self._client.get_attachment_content(attachment['attachment_id'])
759
+ except Exception as e:
760
+ logger.error(
761
+ f"Failed to download attachment {attachment['filename']} for issue {jira_issue_key}: {str(e)}")
762
+ attachment_content = self._client.get(
763
+ path=f"secure/attachment/{attachment['attachment_id']}/{attachment['filename']}", not_json_response=True)
764
+ content_docs = process_content_by_type(attachment_content, attachment['filename'], llm=self.llm, fallback_extensions=[".txt", ".png"])
765
+ attachment_data.append("filename: " + attachment['filename'] + "\ncontent: " + str([doc.page_content for doc in content_docs]))
769
766
 
770
767
  return "\n\n".join(attachment_data)
771
768
 
@@ -229,51 +229,65 @@ def process_document_by_type(content, extension_source: str, document: Document
229
229
  )
230
230
 
231
231
 
232
- def process_content_by_type(content, filename: str, llm=None, chunking_config=None) -> \
232
+ def process_content_by_type(content, filename: str, llm=None, chunking_config=None, fallback_extensions=None) -> \
233
233
  Generator[Document, None, None]:
234
234
  """Process the content of a file based on its type using a configured loader."""
235
235
  temp_file_path = None
236
- try:
237
- match = re.search(r'\.([^.]+)$', filename)
238
- extension = f".{match.group(1).lower()}" if match else ".txt"
239
-
240
- with tempfile.NamedTemporaryFile(mode='w+b', suffix=extension, delete=False) as temp_file:
241
- temp_file_path = temp_file.name
242
- if content is None:
243
- logger.warning(
244
- f"'{IndexerKeywords.CONTENT_IN_BYTES.value}' ie expected but not found in document metadata.")
245
- return []
246
-
247
- temp_file.write(content)
248
- temp_file.flush()
249
-
250
- loader_config = loaders_map.get(extension)
251
- if not loader_config:
252
- logger.warning(f"No loader found for file extension: {extension}. File: {temp_file_path}")
253
- return []
254
-
255
- loader_cls = loader_config['class']
256
- loader_kwargs = loader_config['kwargs']
257
- # Determine which loader configuration keys are allowed to be overridden by user input.
258
- # If 'allowed_to_override' is specified in the loader configuration, use it; otherwise, allow all keys in loader_kwargs.
259
- allowed_to_override = loader_config.get('allowed_to_override', list(loader_kwargs.keys()))
260
- # If a chunking_config is provided and contains custom configuration for the current file extension,
261
- # update loader_kwargs with user-supplied values, but only for keys explicitly permitted in allowed_to_override.
262
- # This ensures that only safe and intended parameters can be customized, preventing accidental or unauthorized changes
263
- # to critical loader settings.
264
- if chunking_config and (users_config_for_extension := chunking_config.get(extension, {})):
265
- for key in set(users_config_for_extension.keys()) & set(allowed_to_override):
266
- loader_kwargs[key] = users_config_for_extension[key]
267
- if LoaderProperties.LLM.value in loader_kwargs:
268
- loader_kwargs[LoaderProperties.LLM.value] = llm
269
- if LoaderProperties.PROMPT_DEFAULT.value in loader_kwargs:
270
- loader_kwargs.pop(LoaderProperties.PROMPT_DEFAULT.value)
271
- loader_kwargs[LoaderProperties.PROMPT.value] = image_processing_prompt
272
- loader = loader_cls(file_path=temp_file_path, **loader_kwargs)
273
- yield from loader.load()
274
- finally:
275
- if temp_file_path and os.path.exists(temp_file_path):
276
- os.remove(temp_file_path)
236
+ extensions = fallback_extensions if fallback_extensions else []
237
+ match = re.search(r'\.([^.]+)$', filename)
238
+
239
+ if match:
240
+ extensions.insert(0, f".{match.group(1).lower()}")
241
+ elif not extensions:
242
+ extensions = [".txt"]
243
+
244
+ for extension in extensions:
245
+ try:
246
+ with tempfile.NamedTemporaryFile(mode='w+b', suffix=extension, delete=False) as temp_file:
247
+ temp_file_path = temp_file.name
248
+ if content is None:
249
+ logger.warning(
250
+ f"'{IndexerKeywords.CONTENT_IN_BYTES.value}' ie expected but not found in document metadata.")
251
+ return []
252
+
253
+ temp_file.write(content)
254
+ temp_file.flush()
255
+
256
+ loader_config = loaders_map.get(extension)
257
+ if not loader_config:
258
+ logger.warning(f"No loader found for file extension: {extension}. File: {temp_file_path}")
259
+ return []
260
+
261
+ loader_cls = loader_config['class']
262
+ loader_kwargs = loader_config['kwargs']
263
+ # Determine which loader configuration keys are allowed to be overridden by user input.
264
+ # If 'allowed_to_override' is specified in the loader configuration, use it; otherwise, allow all keys in loader_kwargs.
265
+ allowed_to_override = loader_config.get('allowed_to_override', list(loader_kwargs.keys()))
266
+ # If a chunking_config is provided and contains custom configuration for the current file extension,
267
+ # update loader_kwargs with user-supplied values, but only for keys explicitly permitted in allowed_to_override.
268
+ # This ensures that only safe and intended parameters can be customized, preventing accidental or unauthorized changes
269
+ # to critical loader settings.
270
+ if chunking_config and (users_config_for_extension := chunking_config.get(extension, {})):
271
+ for key in set(users_config_for_extension.keys()) & set(allowed_to_override):
272
+ loader_kwargs[key] = users_config_for_extension[key]
273
+ if LoaderProperties.LLM.value in loader_kwargs:
274
+ loader_kwargs[LoaderProperties.LLM.value] = llm
275
+ if LoaderProperties.PROMPT_DEFAULT.value in loader_kwargs:
276
+ loader_kwargs.pop(LoaderProperties.PROMPT_DEFAULT.value)
277
+ loader_kwargs[LoaderProperties.PROMPT.value] = image_processing_prompt
278
+ loader = loader_cls(file_path=temp_file_path, **loader_kwargs)
279
+ yield from loader.load()
280
+ break
281
+ except Exception as e:
282
+ if fallback_extensions:
283
+ logger.warning(f"Error loading attachment: {str(e)} for file {temp_file_path} (extension: {extension})")
284
+ logger.warning(f"Continuing with fallback extensions: {fallback_extensions}.")
285
+ continue
286
+ else:
287
+ raise e
288
+ finally:
289
+ if temp_file_path and os.path.exists(temp_file_path):
290
+ os.remove(temp_file_path)
277
291
 
278
292
  # FIXME copied from langchain_core/utils/strings.py of 0.3.74 version
279
293
  # https://github.com/langchain-ai/langchain/pull/32157
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.361
3
+ Version: 0.3.363
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
@@ -101,7 +101,7 @@ alita_sdk/runtime/toolkits/configurations.py,sha256=kIDAlnryPQfbZyFxV-9SzN2-Vefz
101
101
  alita_sdk/runtime/toolkits/datasource.py,sha256=qk78OdPoReYPCWwahfkKLbKc4pfsu-061oXRryFLP6I,2498
102
102
  alita_sdk/runtime/toolkits/prompt.py,sha256=WIpTkkVYWqIqOWR_LlSWz3ug8uO9tm5jJ7aZYdiGRn0,1192
103
103
  alita_sdk/runtime/toolkits/subgraph.py,sha256=wwUK8JjPXkGzyVZ3tAukmvST6eGbqx_U11rpnmbrvtg,2105
104
- alita_sdk/runtime/toolkits/tools.py,sha256=YkDvbN1TdWNO-wHbbJbNeonGCwCPlxsuegH33mCfE-I,8303
104
+ alita_sdk/runtime/toolkits/tools.py,sha256=WBTU-ou5u0R9QLses5N_JHP2TryrsWUr_gY8uG5xY3E,8319
105
105
  alita_sdk/runtime/toolkits/vectorstore.py,sha256=BGppQADa1ZiLO17fC0uCACTTEvPHlodEDYEzUcBRbAA,2901
106
106
  alita_sdk/runtime/tools/__init__.py,sha256=TbHPnDtCdQvNzK1YQnk_ufkuI7FgHfvY1-JWUgycZhQ,497
107
107
  alita_sdk/runtime/tools/agent.py,sha256=m98QxOHwnCRTT9j18Olbb5UPS8-ZGeQaGiUyZJSyFck,3162
@@ -247,7 +247,7 @@ alita_sdk/tools/github/schemas.py,sha256=TxEWR3SjDKVwzo9i2tLnss_uPAv85Mh7oWjvQvY
247
247
  alita_sdk/tools/github/tool.py,sha256=Jnnv5lenV5ds8AAdyo2m8hSzyJ117HZBjzHC6T1ck-M,1037
248
248
  alita_sdk/tools/github/tool_prompts.py,sha256=y6ZW_FpUCE87Uop3WuQAZVRnzxO5t7xjBOI5bCqiluw,30194
249
249
  alita_sdk/tools/gitlab/__init__.py,sha256=iis7RHD3YgKWxF_ryTfdtA8RPGV-W8zUfy4BgiTDADw,4540
250
- alita_sdk/tools/gitlab/api_wrapper.py,sha256=jziPnjBkJE7TRIAyGsV7s9sX74NuL97yP1UiNKzzK8s,22626
250
+ alita_sdk/tools/gitlab/api_wrapper.py,sha256=gmL6o6yZDJKvAOVVgd-gG4wyjD3SlxJ4Ipoyz0GvqW8,22799
251
251
  alita_sdk/tools/gitlab/tools.py,sha256=vOGTlSaGaFmWn6LS6YFP-FuTqUPun9vnv1VrUcUHAZQ,16500
252
252
  alita_sdk/tools/gitlab/utils.py,sha256=Z2XiqIg54ouqqt1to-geFybmkCb1I6bpE91wfnINH1I,2320
253
253
  alita_sdk/tools/gitlab_org/__init__.py,sha256=PSTsC4BcPoyDv03Wj9VQHrEGUeR8hw4MRarB64VeqFg,3865
@@ -263,7 +263,7 @@ alita_sdk/tools/google/bigquery/tool.py,sha256=Esf9Hsp8I0e7-5EdkFqQ-bid0cfrg-bfS
263
263
  alita_sdk/tools/google_places/__init__.py,sha256=QtmBCI0bHDK79u4hsCSWFcUihu-h4EmPSh9Yll7zz3w,3590
264
264
  alita_sdk/tools/google_places/api_wrapper.py,sha256=7nZly6nk4f4Tm7s2MVdnnwlb-1_WHRrDhyjDiqoyPjA,4674
265
265
  alita_sdk/tools/jira/__init__.py,sha256=G-9qnOYKFWM_adG0QFexh5-2pj_WaxIxxZanB3ARFqI,6339
266
- alita_sdk/tools/jira/api_wrapper.py,sha256=Z1pL7mTERv9TZFJNewe67kNeWcT5XCb7l8scmz6lx88,82745
266
+ alita_sdk/tools/jira/api_wrapper.py,sha256=N-aPpzV1CZaB5uU56sqXO4t2FEdmK2lVQt3VU9EYY0g,82584
267
267
  alita_sdk/tools/keycloak/__init__.py,sha256=0WB9yXMUUAHQRni1ghDEmd7GYa7aJPsTVlZgMCM9cQ0,3050
268
268
  alita_sdk/tools/keycloak/api_wrapper.py,sha256=cOGr0f3S3-c6tRDBWI8wMnetjoNSxiV5rvC_0VHb8uw,3100
269
269
  alita_sdk/tools/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -330,7 +330,7 @@ alita_sdk/tools/testrail/__init__.py,sha256=Xg4nVjULL_D8JpIXLYXppnwUfGF4-lguFwKH
330
330
  alita_sdk/tools/testrail/api_wrapper.py,sha256=tQcGlFJmftvs5ZiO4tsP19fCo4CrJeq_UEvQR1liVfE,39891
331
331
  alita_sdk/tools/utils/__init__.py,sha256=W9rCCUPtHCP5nGAbWp0n5jaNA84572aiRoqKneBnaS4,3330
332
332
  alita_sdk/tools/utils/available_tools_decorator.py,sha256=IbrdfeQkswxUFgvvN7-dyLMZMyXLiwvX7kgi3phciCk,273
333
- alita_sdk/tools/utils/content_parser.py,sha256=4GCiTwoJ1zcTHi1nXLf_qJEET7aO-AWjk3yGgXhmO9g,14529
333
+ alita_sdk/tools/utils/content_parser.py,sha256=TuKAPUzIZx9F-pzHiVyrCFpI5emrGaOF8DgWHJP2cM4,15235
334
334
  alita_sdk/tools/vector_adapters/VectorStoreAdapter.py,sha256=ypBEAkFRGHv5edW0N9rdo1yKurNGQ4pRVEWtrN_7SeA,17656
335
335
  alita_sdk/tools/vector_adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
336
336
  alita_sdk/tools/xray/__init__.py,sha256=eOMWP8VamFbbJgt1xrGpGPqB9ByOTA0Cd3LCaETzGk4,4376
@@ -352,8 +352,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=kT0TbmMvuKhDUZc0i7KO18O38JM9S
352
352
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=0ne8XLJEQSLOWfzd2HdnqOYmQlUliKHbBED5kW_Vias,2895
353
353
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=kmw_xol8YIYFplBLWTqP_VKPRhL_1ItDD0_vXTe_UuI,14906
354
354
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=R371waHsms4sllHCbijKYs90C-9Yu0sSR3N4SUfQOgU,5066
355
- alita_sdk-0.3.361.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
- alita_sdk-0.3.361.dist-info/METADATA,sha256=AU8IDIqqPDm_po6-skVYhjU161VVLGLtonTFhATD3Z8,19071
357
- alita_sdk-0.3.361.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
- alita_sdk-0.3.361.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
- alita_sdk-0.3.361.dist-info/RECORD,,
355
+ alita_sdk-0.3.363.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
+ alita_sdk-0.3.363.dist-info/METADATA,sha256=qK4a9UTuGlSWd7Is3IBJqwYRwA1PBy8aWD7ZH-kgXLE,19071
357
+ alita_sdk-0.3.363.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
+ alita_sdk-0.3.363.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
+ alita_sdk-0.3.363.dist-info/RECORD,,