alita-sdk 0.3.365__py3-none-any.whl → 0.3.366__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/langchain/langraph_agent.py +6 -4
- alita_sdk/tools/sql/api_wrapper.py +49 -21
- {alita_sdk-0.3.365.dist-info → alita_sdk-0.3.366.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.365.dist-info → alita_sdk-0.3.366.dist-info}/RECORD +7 -7
- {alita_sdk-0.3.365.dist-info → alita_sdk-0.3.366.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.365.dist-info → alita_sdk-0.3.366.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.365.dist-info → alita_sdk-0.3.366.dist-info}/top_level.txt +0 -0
|
@@ -795,15 +795,17 @@ class LangGraphAgentRunnable(CompiledStateGraph):
|
|
|
795
795
|
output = result['messages'][-1].content
|
|
796
796
|
except:
|
|
797
797
|
output = list(result.values())[-1]
|
|
798
|
-
thread_id = None
|
|
799
798
|
config_state = self.get_state(config)
|
|
800
|
-
|
|
801
|
-
|
|
799
|
+
is_execution_finished = not config_state.next
|
|
800
|
+
if is_execution_finished:
|
|
801
|
+
thread_id = None
|
|
802
|
+
|
|
803
|
+
|
|
802
804
|
|
|
803
805
|
result_with_state = {
|
|
804
806
|
"output": output,
|
|
805
807
|
"thread_id": thread_id,
|
|
806
|
-
"execution_finished":
|
|
808
|
+
"execution_finished": is_execution_finished
|
|
807
809
|
}
|
|
808
810
|
|
|
809
811
|
# Include all state values in the result
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Optional
|
|
3
3
|
|
|
4
|
-
from pydantic import
|
|
5
|
-
from pydantic.fields import PrivateAttr
|
|
4
|
+
from pydantic import create_model, SecretStr, model_validator
|
|
5
|
+
from pydantic.fields import PrivateAttr, Field
|
|
6
6
|
from sqlalchemy import create_engine, text, inspect, Engine
|
|
7
7
|
from sqlalchemy.orm import sessionmaker
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ class SQLApiWrapper(BaseToolApiWrapper):
|
|
|
27
27
|
username: str
|
|
28
28
|
password: SecretStr
|
|
29
29
|
database_name: str
|
|
30
|
-
_client: Optional[Engine] = PrivateAttr()
|
|
30
|
+
_client: Optional[Engine] = PrivateAttr(default=None)
|
|
31
31
|
|
|
32
32
|
@model_validator(mode='before')
|
|
33
33
|
@classmethod
|
|
@@ -35,27 +35,55 @@ class SQLApiWrapper(BaseToolApiWrapper):
|
|
|
35
35
|
for field in SQLConfig.model_fields:
|
|
36
36
|
if field not in values or not values[field]:
|
|
37
37
|
raise ValueError(f"{field} is a required field and must be provided.")
|
|
38
|
+
return values
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
port = values['port']
|
|
45
|
-
|
|
46
|
-
if dialect == SQLDialect.POSTGRES:
|
|
47
|
-
connection_string = f'postgresql+psycopg2://{username}:{password}@{host}:{port}/{database_name}'
|
|
48
|
-
elif dialect == SQLDialect.MYSQL:
|
|
49
|
-
connection_string = f'mysql+pymysql://{username}:{password}@{host}:{port}/{database_name}'
|
|
40
|
+
def _mask_password_in_error(self, error_message: str) -> str:
|
|
41
|
+
"""Mask password in error messages, showing only last 4 characters."""
|
|
42
|
+
password_str = self.password.get_secret_value()
|
|
43
|
+
if len(password_str) <= 4:
|
|
44
|
+
masked_password = "****"
|
|
50
45
|
else:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
46
|
+
masked_password = "****" + password_str[-4:]
|
|
47
|
+
|
|
48
|
+
# Replace password in error message
|
|
49
|
+
return error_message.replace(password_str, masked_password)
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def client(self) -> Engine:
|
|
53
|
+
"""Lazy property to create and return database engine with error handling."""
|
|
54
|
+
if self._client is None:
|
|
55
|
+
try:
|
|
56
|
+
dialect = self.dialect
|
|
57
|
+
host = self.host
|
|
58
|
+
username = self.username
|
|
59
|
+
password = self.password.get_secret_value()
|
|
60
|
+
database_name = self.database_name
|
|
61
|
+
port = self.port
|
|
62
|
+
|
|
63
|
+
if dialect == SQLDialect.POSTGRES:
|
|
64
|
+
connection_string = f'postgresql+psycopg2://{username}:{password}@{host}:{port}/{database_name}'
|
|
65
|
+
elif dialect == SQLDialect.MYSQL:
|
|
66
|
+
connection_string = f'mysql+pymysql://{username}:{password}@{host}:{port}/{database_name}'
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError(f"Unsupported database type. Supported types are: {[e.value for e in SQLDialect]}")
|
|
69
|
+
|
|
70
|
+
self._client = create_engine(connection_string)
|
|
71
|
+
|
|
72
|
+
# Test the connection
|
|
73
|
+
with self._client.connect() as conn:
|
|
74
|
+
conn.execute(text("SELECT 1"))
|
|
75
|
+
|
|
76
|
+
except Exception as e:
|
|
77
|
+
error_message = str(e)
|
|
78
|
+
masked_error = self._mask_password_in_error(error_message)
|
|
79
|
+
logger.error(f"Database connection failed: {masked_error}")
|
|
80
|
+
raise ValueError(f"Database connection failed: {masked_error}")
|
|
81
|
+
|
|
82
|
+
return self._client
|
|
55
83
|
|
|
56
84
|
def execute_sql(self, sql_query: str):
|
|
57
85
|
"""Executes the provided SQL query on the configured database."""
|
|
58
|
-
engine = self.
|
|
86
|
+
engine = self.client
|
|
59
87
|
maker_session = sessionmaker(bind=engine)
|
|
60
88
|
session = maker_session()
|
|
61
89
|
try:
|
|
@@ -78,7 +106,7 @@ class SQLApiWrapper(BaseToolApiWrapper):
|
|
|
78
106
|
|
|
79
107
|
def list_tables_and_columns(self):
|
|
80
108
|
"""Lists all tables and their columns in the configured database."""
|
|
81
|
-
inspector = inspect(self.
|
|
109
|
+
inspector = inspect(self.client)
|
|
82
110
|
data = {}
|
|
83
111
|
tables = inspector.get_table_names()
|
|
84
112
|
for table in tables:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: alita_sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.366
|
|
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=
|
|
47
|
+
alita_sdk/runtime/langchain/langraph_agent.py,sha256=bQVT70vfIpfAjuqFbVx670XBIdlcvwsXUSltWh2vvxk,48043
|
|
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
|
|
@@ -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=
|
|
325
|
+
alita_sdk/tools/sql/api_wrapper.py,sha256=AHv90ppE2AYB0z8KXeUNUtnC0Bm-g8vtsLMY9GdXP84,4893
|
|
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.
|
|
356
|
-
alita_sdk-0.3.
|
|
357
|
-
alita_sdk-0.3.
|
|
358
|
-
alita_sdk-0.3.
|
|
359
|
-
alita_sdk-0.3.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|