alita-sdk 0.3.459__py3-none-any.whl → 0.3.460__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.
@@ -16,6 +16,18 @@ from ..langchain.utils import propagate_the_input_mapping
16
16
  logger = logging.getLogger(__name__)
17
17
 
18
18
 
19
+ def replace_escaped_newlines(data):
20
+ """
21
+ Replace \\n with \n in all string values recursively.
22
+ Required for sanitization of state variables in code node
23
+ """
24
+ if isinstance(data, dict):
25
+ return {key: replace_escaped_newlines(value) for key, value in data.items()}
26
+ elif isinstance(data, str):
27
+ return data.replace('\\n', '\n')
28
+ else:
29
+ return data
30
+
19
31
  class FunctionTool(BaseTool):
20
32
  name: str = 'FunctionalTool'
21
33
  description: str = 'This is direct call node for tools'
@@ -30,12 +42,13 @@ class FunctionTool(BaseTool):
30
42
  def _prepare_pyodide_input(self, state: Union[str, dict, ToolCall]) -> str:
31
43
  """Prepare input for PyodideSandboxTool by injecting state into the code block."""
32
44
  # add state into the code block here since it might be changed during the execution of the code
33
- state_copy = deepcopy(state)
45
+ state_copy = replace_escaped_newlines(deepcopy(state))
34
46
 
35
47
  del state_copy['messages'] # remove messages to avoid issues with pickling without langchain-core
36
48
  # inject state into the code block as alita_state variable
37
49
  state_json = json.dumps(state_copy, ensure_ascii=False)
38
- pyodide_predata = f'#state dict\nimport json\nalita_state = {repr(state_json)}\n'
50
+ pyodide_predata = f'#state dict\nimport json\nalita_state = json.loads({json.dumps(state_json)})\n'
51
+
39
52
  return pyodide_predata
40
53
 
41
54
  def _handle_pyodide_output(self, tool_result: Any) -> dict:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.459
3
+ Version: 0.3.460
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
@@ -121,7 +121,7 @@ alita_sdk/runtime/tools/application.py,sha256=RCGe-mRfj8372gTFkEX2xBvcYhw7IKdU1t
121
121
  alita_sdk/runtime/tools/artifact.py,sha256=u3szFwZqguHrPZ3tZJ7S_TiZl7cxlT3oHYd6zbdpRDE,13842
122
122
  alita_sdk/runtime/tools/datasource.py,sha256=pvbaSfI-ThQQnjHG-QhYNSTYRnZB0rYtZFpjCfpzxYI,2443
123
123
  alita_sdk/runtime/tools/echo.py,sha256=spw9eCweXzixJqHnZofHE1yWiSUa04L4VKycf3KCEaM,486
124
- alita_sdk/runtime/tools/function.py,sha256=0O29IFs0ZupXxqXwGa4Pmm_QdxulUR3ZDGowXDPRgv8,6557
124
+ alita_sdk/runtime/tools/function.py,sha256=1kBVMgLNjoE2yQb5rX8O6MR82rDaylJSrj2Hd-JdkN8,7002
125
125
  alita_sdk/runtime/tools/graph.py,sha256=7jImBBSEdP5Mjnn2keOiyUwdGDFhEXLUrgUiugO3mgA,3503
126
126
  alita_sdk/runtime/tools/image_generation.py,sha256=Kls9D_ke_SK7xmVr7I9SlQcAEBJc86gf66haN0qIj9k,7469
127
127
  alita_sdk/runtime/tools/indexer_tool.py,sha256=whSLPevB4WD6dhh2JDXEivDmTvbjiMV1MrPl9cz5eLA,4375
@@ -368,9 +368,9 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=kT0TbmMvuKhDUZc0i7KO18O38JM9S
368
368
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=Gl1YAFaMMufTNjIpnuo_c_lbDsQkmproYdZz2ZppgJ4,3007
369
369
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=kmw_xol8YIYFplBLWTqP_VKPRhL_1ItDD0_vXTe_UuI,14906
370
370
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=R371waHsms4sllHCbijKYs90C-9Yu0sSR3N4SUfQOgU,5066
371
- alita_sdk-0.3.459.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
372
- alita_sdk-0.3.459.dist-info/METADATA,sha256=7Oo76t6BYB0tv0jHbuloCQQrwMpcw7Ga_jqI1KVZeJ0,19298
373
- alita_sdk-0.3.459.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
374
- alita_sdk-0.3.459.dist-info/entry_points.txt,sha256=sSxsIZu9YjVGsgf-5mHC631FeBcT6f2vUjm0A_L9tcU,53
375
- alita_sdk-0.3.459.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
376
- alita_sdk-0.3.459.dist-info/RECORD,,
371
+ alita_sdk-0.3.460.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
372
+ alita_sdk-0.3.460.dist-info/METADATA,sha256=TEpptFsgT4y0uXNkzXHpOpFagAU_xZ8lCiU6sbqVGbo,19298
373
+ alita_sdk-0.3.460.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
374
+ alita_sdk-0.3.460.dist-info/entry_points.txt,sha256=sSxsIZu9YjVGsgf-5mHC631FeBcT6f2vUjm0A_L9tcU,53
375
+ alita_sdk-0.3.460.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
376
+ alita_sdk-0.3.460.dist-info/RECORD,,