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

@@ -786,13 +786,14 @@ class LangGraphAgentRunnable(CompiledStateGraph):
786
786
  else:
787
787
  result = super().invoke(input, config=config, *args, **kwargs)
788
788
  try:
789
- if self.output_variables and self.output_variables[0] != "messages":
790
- # If output_variables are specified, use the value of first one or use the last messages as default
791
- output = result.get(self.output_variables[0])
792
- if not output:
793
- output = result['messages'][-1].content
794
- else:
795
- output = result['messages'][-1].content
789
+ # if self.output_variables and self.output_variables[0] != "messages":
790
+ # # If output_variables are specified, use the value of first one or use the last messages as default
791
+ # output = result.get(self.output_variables[0])
792
+ # if not output:
793
+ # output = result['messages'][-1].content
794
+ # else:
795
+ # output = result['messages'][-1].content
796
+ output = next((msg.content for msg in reversed(result['messages']) if not isinstance(msg, HumanMessage)), result['messages'][-1].content)
796
797
  except:
797
798
  output = list(result.values())[-1]
798
799
  config_state = self.get_state(config)
@@ -340,7 +340,7 @@ class PostmanApiWrapper(BaseToolApiWrapper):
340
340
  raise ToolException(
341
341
  f"Invalid JSON response from Postman API: {str(e)}")
342
342
 
343
- def _apply_authentication(self, headers, params, all_variables, resolve_variables):
343
+ def _apply_authentication(self, headers, params, all_variables, native_auth, resolve_variables):
344
344
  """Apply authentication based on environment_config auth settings.
345
345
 
346
346
  Supports multiple authentication types:
@@ -363,14 +363,15 @@ class PostmanApiWrapper(BaseToolApiWrapper):
363
363
  import base64
364
364
 
365
365
  # Handle structured auth configuration only - no backward compatibility
366
- auth_config = self.environment_config.get('auth')
366
+ auth_config = self.environment_config.get('auth', native_auth)
367
367
  if auth_config and isinstance(auth_config, dict):
368
368
  auth_type = auth_config.get('type', '').lower()
369
369
  auth_params = auth_config.get('params', {})
370
370
 
371
371
  if auth_type == 'bearer':
372
372
  # Bearer token authentication
373
- token = resolve_variables(str(auth_params.get('token', '')))
373
+ tokent_raw = auth_config.get('bearer', [{}])[0].get('value', '')
374
+ token = resolve_variables(str(tokent_raw))
374
375
  if token:
375
376
  headers['Authorization'] = f'Bearer {token}'
376
377
 
@@ -739,7 +740,7 @@ class PostmanApiWrapper(BaseToolApiWrapper):
739
740
  all_variables = {}
740
741
 
741
742
  # 1. Start with environment_config variables (lowest priority)
742
- all_variables.update(self.environment_config)
743
+ all_variables.update(self._get_variables_from_env_config())
743
744
 
744
745
  # 2. Add collection variables
745
746
  collection_variables = collection_data.get('variable', [])
@@ -760,8 +761,8 @@ class PostmanApiWrapper(BaseToolApiWrapper):
760
761
  import re
761
762
  def replace_var(match):
762
763
  var_name = match.group(1)
763
- value = all_variables.get(var_name, match.group(0))
764
- return resolve_variables(value) if isinstance(value, str) else value
764
+ value = all_variables.get(var_name, None)
765
+ return resolve_variables(str(value)) if value else match.group(0)
765
766
 
766
767
  return re.sub(r'\{\{([^}]+)\}\}', replace_var, text)
767
768
 
@@ -792,7 +793,7 @@ class PostmanApiWrapper(BaseToolApiWrapper):
792
793
  headers = {}
793
794
 
794
795
  # Handle authentication from environment_config
795
- self._apply_authentication(headers, params, all_variables, resolve_variables)
796
+ self._apply_authentication(headers, params, all_variables, request_data.get('auth', None), resolve_variables)
796
797
 
797
798
  # Add headers from request
798
799
  request_headers = request_data.get('header', [])
@@ -1641,7 +1642,7 @@ class PostmanApiWrapper(BaseToolApiWrapper):
1641
1642
 
1642
1643
  # Find the request
1643
1644
  request_item = self.analyzer.find_request_by_path(
1644
- collection_data["item"], request_path)
1645
+ collection_data["item"], request_path, collection_data.get("auth", None))
1645
1646
  if not request_item:
1646
1647
  raise ToolException(f"Request '{request_path}' not found")
1647
1648
 
@@ -2162,3 +2163,12 @@ class PostmanApiWrapper(BaseToolApiWrapper):
2162
2163
  parse_items(items)
2163
2164
 
2164
2165
  return result
2166
+
2167
+ def _get_variables_from_env_config(self):
2168
+ """Extracts all enabled variables from the 'values' field in environment_config."""
2169
+ result = {}
2170
+ values = self.environment_config.get("values", [])
2171
+ for var in values:
2172
+ if var.get("enabled", True) and "key" in var and "value" in var:
2173
+ result[var["key"]] = var["value"]
2174
+ return result
@@ -1049,13 +1049,14 @@ class PostmanAnalyzer:
1049
1049
  find_in_items(items, path_parts)
1050
1050
  return results
1051
1051
 
1052
- def find_request_by_path(self, items: List[Dict], request_path: str) -> Optional[Dict]:
1052
+ def find_request_by_path(self, items: List[Dict], request_path: str, auth = None) -> Optional[Dict]:
1053
1053
  """Find a request by its path."""
1054
1054
  path_parts = [part.strip() for part in request_path.split('/') if part.strip()]
1055
1055
  if not path_parts:
1056
1056
  return None
1057
1057
 
1058
1058
  current_items = items
1059
+ current_auth = auth
1059
1060
 
1060
1061
  # Navigate through folders to the request
1061
1062
  for i, part in enumerate(path_parts):
@@ -1065,6 +1066,9 @@ class PostmanAnalyzer:
1065
1066
  if i == len(path_parts) - 1:
1066
1067
  # This should be the request
1067
1068
  if item.get('request'):
1069
+ # if request has no auth, inherit from parent
1070
+ if not item['request'].get('auth') and current_auth:
1071
+ item['request']['auth'] = current_auth
1068
1072
  return item
1069
1073
  else:
1070
1074
  return None
@@ -1072,6 +1076,9 @@ class PostmanAnalyzer:
1072
1076
  # This should be a folder
1073
1077
  if item.get('item'):
1074
1078
  current_items = item['item']
1079
+ # Update current_auth if folder has auth
1080
+ if item.get('auth'):
1081
+ current_auth = item['auth']
1075
1082
  found = True
1076
1083
  break
1077
1084
  else:
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  from typing import Optional
3
3
 
4
+ from langchain_core.tools import ToolException
4
5
  from pydantic import create_model, SecretStr, model_validator
5
6
  from pydantic.fields import PrivateAttr, Field
6
7
  from sqlalchemy import create_engine, text, inspect, Engine
@@ -45,8 +46,11 @@ class SQLApiWrapper(BaseToolApiWrapper):
45
46
  else:
46
47
  masked_password = "****" + password_str[-4:]
47
48
 
48
- # Replace password in error message
49
- return error_message.replace(password_str, masked_password)
49
+ # Replace all occurrences of the password, and any substring of the password that may appear in the error message
50
+ for part in [password_str, password_str.replace('@', ''), password_str.split('@')[-1]]:
51
+ if part and part in error_message:
52
+ error_message = error_message.replace(part, masked_password)
53
+ return error_message
50
54
 
51
55
  @property
52
56
  def client(self) -> Engine:
@@ -81,6 +85,21 @@ class SQLApiWrapper(BaseToolApiWrapper):
81
85
 
82
86
  return self._client
83
87
 
88
+ def _handle_database_errors(func):
89
+ """Decorator to catch exceptions and mask passwords in error messages."""
90
+
91
+ def wrapper(self, *args, **kwargs):
92
+ try:
93
+ return func(self, *args, **kwargs)
94
+ except Exception as e:
95
+ error_message = str(e)
96
+ masked_error = self._mask_password_in_error(error_message)
97
+ logger.error(f"Database operation failed in {func.__name__}: {masked_error}")
98
+ raise ToolException(masked_error)
99
+
100
+ return wrapper
101
+
102
+ @_handle_database_errors
84
103
  def execute_sql(self, sql_query: str):
85
104
  """Executes the provided SQL query on the configured database."""
86
105
  engine = self.client
@@ -104,6 +123,7 @@ class SQLApiWrapper(BaseToolApiWrapper):
104
123
  finally:
105
124
  session.close()
106
125
 
126
+ @_handle_database_errors
107
127
  def list_tables_and_columns(self):
108
128
  """Lists all tables and their columns in the configured database."""
109
129
  inspector = inspect(self.client)
@@ -137,4 +157,4 @@ class SQLApiWrapper(BaseToolApiWrapper):
137
157
  "description": self.list_tables_and_columns.__doc__,
138
158
  "args_schema": SQLNoInput,
139
159
  }
140
- ]
160
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.366
3
+ Version: 0.3.368
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
@@ -44,7 +44,7 @@ alita_sdk/runtime/langchain/assistant.py,sha256=2tH8je9uKegIIIZUuiGU4zqRVg7jyQas
44
44
  alita_sdk/runtime/langchain/chat_message_template.py,sha256=kPz8W2BG6IMyITFDA5oeb5BxVRkHEVZhuiGl4MBZKdc,2176
45
45
  alita_sdk/runtime/langchain/constants.py,sha256=eHVJ_beJNTf1WJo4yq7KMK64fxsRvs3lKc34QCXSbpk,3319
46
46
  alita_sdk/runtime/langchain/indexer.py,sha256=0ENHy5EOhThnAiYFc7QAsaTNp9rr8hDV_hTK8ahbatk,37592
47
- alita_sdk/runtime/langchain/langraph_agent.py,sha256=bQVT70vfIpfAjuqFbVx670XBIdlcvwsXUSltWh2vvxk,48043
47
+ alita_sdk/runtime/langchain/langraph_agent.py,sha256=NvoaAZLgb-gcRv14LnZHBFajWHTbimx6QJ9EyOaomoE,48207
48
48
  alita_sdk/runtime/langchain/mixedAgentParser.py,sha256=M256lvtsL3YtYflBCEp-rWKrKtcY1dJIyRGVv7KW9ME,2611
49
49
  alita_sdk/runtime/langchain/mixedAgentRenderes.py,sha256=asBtKqm88QhZRILditjYICwFVKF5KfO38hu2O-WrSWE,5964
50
50
  alita_sdk/runtime/langchain/store_manager.py,sha256=i8Fl11IXJhrBXq1F1ukEVln57B1IBe-tqSUvfUmBV4A,2218
@@ -297,8 +297,8 @@ alita_sdk/tools/pandas/statsmodels/descriptive.py,sha256=APdofBnEiRhMrn6tLKwH076
297
297
  alita_sdk/tools/pandas/statsmodels/hypothesis_testing.py,sha256=fdNAayMB3W7avMfKJCcbf2_P54vUXbq8KVebOB48348,10508
298
298
  alita_sdk/tools/pandas/statsmodels/regression.py,sha256=Y1pWK4u_qzrfA740K-FX0nZ5FREGGPk8mfvykPIYoiI,9164
299
299
  alita_sdk/tools/postman/__init__.py,sha256=2bvyhAqmAwXjswiPiuMaB7caU44k5rAWyeR58pc1ksU,4472
300
- alita_sdk/tools/postman/api_wrapper.py,sha256=TY8ddkrFWTsMWK9Dd0cTXNCmihhfbxFw8EqK-kBPwv4,96458
301
- alita_sdk/tools/postman/postman_analysis.py,sha256=2d-Oi2UORosIePIUyncSONw9hY7dw8Zc7BQvCd4aqpg,45115
300
+ alita_sdk/tools/postman/api_wrapper.py,sha256=bTVDEeezRp9-fhot4MFX3-DOr_soJB5eOMVjNPmg6Fg,97013
301
+ alita_sdk/tools/postman/postman_analysis.py,sha256=ckc2BfKEop0xnmLPksVRE_Y94ixuqOGowaClBzHCSn4,45560
302
302
  alita_sdk/tools/pptx/__init__.py,sha256=vVUrWnj7KWJgEk9oxGSsCAQ2SMSXrp_SFOdUHYQKcAo,3444
303
303
  alita_sdk/tools/pptx/pptx_wrapper.py,sha256=yyCYcTlIY976kJ4VfPo4dyxj4yeii9j9TWP6W8ZIpN8,29195
304
304
  alita_sdk/tools/qtest/__init__.py,sha256=Jf0xo5S_4clXR2TfCbJbB1sFgCbcFQRM-YYX2ltWBzo,4461
@@ -322,7 +322,7 @@ alita_sdk/tools/sharepoint/utils.py,sha256=fZ1YzAu5CTjKSZeslowpOPH974902S8vCp1Wu
322
322
  alita_sdk/tools/slack/__init__.py,sha256=YiPAoRc6y6uVpfHl0K1Qi-flcyPlWFIMVcVbhicGWXY,3990
323
323
  alita_sdk/tools/slack/api_wrapper.py,sha256=5VrV7iSGno8ZcDzEHdGPNhInhtODGPPvAzoZ9W9iQWE,14009
324
324
  alita_sdk/tools/sql/__init__.py,sha256=F3eewPEKqVh3gZdNTUvcoFPOgG9Mn11qKoadtCmhQ4Q,3484
325
- alita_sdk/tools/sql/api_wrapper.py,sha256=AHv90ppE2AYB0z8KXeUNUtnC0Bm-g8vtsLMY9GdXP84,4893
325
+ alita_sdk/tools/sql/api_wrapper.py,sha256=1VkwnMBr7hGn-LsXXhG774QQQTHvUZilnDuflN2pQes,5810
326
326
  alita_sdk/tools/sql/models.py,sha256=AKJgSl_kEEz4fZfw3kbvdGHXaRZ-yiaqfJOB6YOj3i0,641
327
327
  alita_sdk/tools/testio/__init__.py,sha256=NEvQtzsffqAXryaffVk0GpdcxZQ1AMkfeztnxHwNql4,2798
328
328
  alita_sdk/tools/testio/api_wrapper.py,sha256=BvmL5h634BzG6p7ajnQLmj-uoAw1gjWnd4FHHu1h--Q,21638
@@ -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.366.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
- alita_sdk-0.3.366.dist-info/METADATA,sha256=wlps-YB4WTVcMnF8BT-mKcSZPxM8bMLQUpPkG1kgaeY,19071
357
- alita_sdk-0.3.366.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
- alita_sdk-0.3.366.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
- alita_sdk-0.3.366.dist-info/RECORD,,
355
+ alita_sdk-0.3.368.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
+ alita_sdk-0.3.368.dist-info/METADATA,sha256=D_3Xrhff7tC9ezLl5uIYNB2gf32WvzqdvJJIJb8KeZ8,19071
357
+ alita_sdk-0.3.368.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
+ alita_sdk-0.3.368.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
+ alita_sdk-0.3.368.dist-info/RECORD,,