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

@@ -556,11 +556,11 @@ def create_graph(
556
556
  elif node_type == 'code':
557
557
  from ..tools.sandbox import create_sandbox_tool
558
558
  sandbox_tool = create_sandbox_tool(stateful=False, allow_net=True)
559
- code = node.get('code', "return 'Code block is empty'")
559
+ code_data = node.get('code', {'type': 'fixed', 'value': "return 'Code block is empty'"})
560
560
  lg_builder.add_node(node_id, FunctionTool(
561
561
  tool=sandbox_tool, name=node['id'], return_type='dict',
562
562
  output_variables=node.get('output', []),
563
- input_mapping={'code': {'type': 'fixed', 'value': code}},
563
+ input_mapping={'code': code_data},
564
564
  input_variables=node.get('input', ['messages']),
565
565
  structured_output=node.get('structured_output', False),
566
566
  alita_client=kwargs.get('alita_client', None)
@@ -177,7 +177,11 @@ def propagate_the_input_mapping(input_mapping: dict[str, dict], input_variables:
177
177
  var_dict = create_params(input_variables, source)
178
178
 
179
179
  if value['type'] == 'fstring':
180
- input_data[key] = value['value'].format(**var_dict)
180
+ try:
181
+ input_data[key] = value['value'].format(**var_dict)
182
+ except KeyError as e:
183
+ logger.error(f"KeyError in fstring formatting for key '{key}'. Attempt to find proper data in state.\n{e}")
184
+ input_data[key] = value['value'].format(**state)
181
185
  elif value['type'] == 'fixed':
182
186
  input_data[key] = value['value']
183
187
  else:
@@ -31,13 +31,10 @@ class FunctionTool(BaseTool):
31
31
  """Prepare input for PyodideSandboxTool by injecting state into the code block."""
32
32
  # add state into the code block here since it might be changed during the execution of the code
33
33
  state_copy = deepcopy(state)
34
- # pickle state
35
- import pickle
36
34
 
37
35
  del state_copy['messages'] # remove messages to avoid issues with pickling without langchain-core
38
- serialized_state = pickle.dumps(state_copy)
39
36
  # inject state into the code block as alita_state variable
40
- pyodide_predata = f"""import pickle\nalita_state = pickle.loads({serialized_state})\n"""
37
+ pyodide_predata = f"alita_state = {state_copy}"
41
38
  # add classes related to sandbox client
42
39
  # read the content of alita_sdk/runtime/cliens/sandbox_client.py
43
40
  try:
@@ -64,6 +61,10 @@ class FunctionTool(BaseTool):
64
61
 
65
62
  if self.output_variables:
66
63
  for var in self.output_variables:
64
+ if var == "messages":
65
+ tool_result_converted.update(
66
+ {"messages": [{"role": "assistant", "content": dumps(tool_result)}]})
67
+ continue
67
68
  if isinstance(tool_result, dict) and var in tool_result:
68
69
  tool_result_converted[var] = tool_result[var]
69
70
  else:
@@ -14,6 +14,7 @@ class IndexerKeywords(Enum):
14
14
  INDEX_META_TYPE = 'index_meta'
15
15
  INDEX_META_IN_PROGRESS = 'in_progress'
16
16
  INDEX_META_COMPLETED = 'completed'
17
+ INDEX_META_FAILED = 'failed'
17
18
 
18
19
  # This pattern matches characters that are NOT alphanumeric, underscores, or hyphens
19
20
  clean_string_pattern = re.compile(r'[^a-zA-Z0-9_.-]')
@@ -152,39 +152,43 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
152
152
 
153
153
  def index_data(self, **kwargs):
154
154
  index_name = kwargs.get("index_name")
155
- progress_step = kwargs.get("progress_step")
156
155
  clean_index = kwargs.get("clean_index")
157
156
  chunking_tool = kwargs.get("chunking_tool")
158
157
  chunking_config = kwargs.get("chunking_config")
158
+ result = {"count": 0}
159
159
  #
160
- if clean_index:
161
- self._clean_index(index_name)
162
- #
163
- self.index_meta_init(index_name, kwargs)
164
- #
165
- self._log_tool_event(f"Indexing data into collection with suffix '{index_name}'. It can take some time...")
166
- self._log_tool_event(f"Loading the documents to index...{kwargs}")
167
- documents = self._base_loader(**kwargs)
168
- documents = list(documents) # consume/exhaust generator to count items
169
- documents_count = len(documents)
170
- documents = (doc for doc in documents)
171
- self._log_tool_event(f"Base documents were pre-loaded. "
172
- f"Search for possible document duplicates and remove them from the indexing list...")
173
- documents = self._reduce_duplicates(documents, index_name)
174
- self._log_tool_event(f"Duplicates were removed. "
175
- f"Processing documents to collect dependencies and prepare them for indexing...")
176
- result = self._save_index_generator(documents, documents_count, chunking_tool, chunking_config, index_name=index_name, progress_step=progress_step)
177
- #
178
- self.index_meta_update(index_name, IndexerKeywords.INDEX_META_COMPLETED.value, result)
179
- #
180
- return {"status": "ok", "message": f"successfully indexed {result} documents"}
160
+ try:
161
+ if clean_index:
162
+ self._clean_index(index_name)
163
+ #
164
+ self.index_meta_init(index_name, kwargs)
165
+ #
166
+ self._log_tool_event(f"Indexing data into collection with suffix '{index_name}'. It can take some time...")
167
+ self._log_tool_event(f"Loading the documents to index...{kwargs}")
168
+ documents = self._base_loader(**kwargs)
169
+ documents = list(documents) # consume/exhaust generator to count items
170
+ documents_count = len(documents)
171
+ documents = (doc for doc in documents)
172
+ self._log_tool_event(f"Base documents were pre-loaded. "
173
+ f"Search for possible document duplicates and remove them from the indexing list...")
174
+ documents = self._reduce_duplicates(documents, index_name)
175
+ self._log_tool_event(f"Duplicates were removed. "
176
+ f"Processing documents to collect dependencies and prepare them for indexing...")
177
+ self._save_index_generator(documents, documents_count, chunking_tool, chunking_config, index_name=index_name, result=result)
178
+ #
179
+ self.index_meta_update(index_name, IndexerKeywords.INDEX_META_COMPLETED.value, result["count"])
180
+ #
181
+ return {"status": "ok", "message": f"successfully indexed {result["count"]} documents"}
182
+ except Exception as e:
183
+ self.index_meta_update(index_name, IndexerKeywords.INDEX_META_FAILED.value, result["count"])
184
+ raise e
185
+
181
186
 
182
- def _save_index_generator(self, base_documents: Generator[Document, None, None], base_total: int, chunking_tool, chunking_config, index_name: Optional[str] = None, progress_step: int = 20):
187
+ def _save_index_generator(self, base_documents: Generator[Document, None, None], base_total: int, chunking_tool, chunking_config, result, index_name: Optional[str] = None):
183
188
  self._log_tool_event(f"Base documents are ready for indexing. {base_total} base documents in total to index.")
184
189
  from ..runtime.langchain.interfaces.llm_processor import add_documents
185
190
  #
186
191
  base_doc_counter = 0
187
- total_counter = 0
188
192
  pg_vector_add_docs_chunk = []
189
193
  for base_doc in base_documents:
190
194
  base_doc_counter += 1
@@ -232,10 +236,9 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
232
236
  msg = f"Indexed base document #{base_doc_counter} out of {base_total} (with {dependent_docs_counter} dependencies)."
233
237
  logger.debug(msg)
234
238
  self._log_tool_event(msg)
235
- total_counter += dependent_docs_counter
239
+ result["count"] += dependent_docs_counter
236
240
  if pg_vector_add_docs_chunk:
237
241
  add_documents(vectorstore=self.vectorstore, documents=pg_vector_add_docs_chunk)
238
- return total_counter
239
242
 
240
243
  def _apply_loaders_chunkers(self, documents: Generator[Document, None, None], chunking_tool: str=None, chunking_config=None) -> Generator[Document, None, None]:
241
244
  from ..tools.chunkers import __all__ as chunkers
@@ -537,7 +537,7 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
537
537
  "args_schema": RemoveIndexParams
538
538
  },
539
539
  {
540
- "name": "list_indexes",
540
+ "name": "list_collections",
541
541
  "mode": "list_collections",
542
542
  "ref": self.list_collections,
543
543
  "description": self.list_collections.__doc__,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.377
3
+ Version: 0.3.378
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
@@ -45,11 +45,11 @@ alita_sdk/runtime/langchain/assistant.py,sha256=rCtlB4Yuf9Sl-SSurUpALB4ETdADpGrd
45
45
  alita_sdk/runtime/langchain/chat_message_template.py,sha256=kPz8W2BG6IMyITFDA5oeb5BxVRkHEVZhuiGl4MBZKdc,2176
46
46
  alita_sdk/runtime/langchain/constants.py,sha256=eHVJ_beJNTf1WJo4yq7KMK64fxsRvs3lKc34QCXSbpk,3319
47
47
  alita_sdk/runtime/langchain/indexer.py,sha256=0ENHy5EOhThnAiYFc7QAsaTNp9rr8hDV_hTK8ahbatk,37592
48
- alita_sdk/runtime/langchain/langraph_agent.py,sha256=dUnyIAKe6i96cYeqHKPCiv40OFnKzwrxKgBQHyNPyLI,48649
48
+ alita_sdk/runtime/langchain/langraph_agent.py,sha256=2AjPJQk1TpBzAKsJAPsETtjUF1p9GH5Q-GC51knX1es,48659
49
49
  alita_sdk/runtime/langchain/mixedAgentParser.py,sha256=M256lvtsL3YtYflBCEp-rWKrKtcY1dJIyRGVv7KW9ME,2611
50
50
  alita_sdk/runtime/langchain/mixedAgentRenderes.py,sha256=asBtKqm88QhZRILditjYICwFVKF5KfO38hu2O-WrSWE,5964
51
51
  alita_sdk/runtime/langchain/store_manager.py,sha256=i8Fl11IXJhrBXq1F1ukEVln57B1IBe-tqSUvfUmBV4A,2218
52
- alita_sdk/runtime/langchain/utils.py,sha256=tzoNe8V8B7nMgDFfQhQrjQehZDIQGH0zYU1uOvz2Sio,6884
52
+ alita_sdk/runtime/langchain/utils.py,sha256=hWWIRKov7X54lr43zH8m214gOul8KLT5YOShdFZjFjs,7128
53
53
  alita_sdk/runtime/langchain/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  alita_sdk/runtime/langchain/agents/xml_chat.py,sha256=Mx7PK5T97_GrFCwHHZ3JZP42S7MwtUzV0W-_8j6Amt8,6212
55
55
  alita_sdk/runtime/langchain/document_loaders/AlitaBDDScenariosLoader.py,sha256=4kFU1ijrM1Jw7cywQv8mUiBHlE6w-uqfzSZP4hUV5P4,3771
@@ -110,7 +110,7 @@ alita_sdk/runtime/tools/application.py,sha256=z3vLZODs-_xEEnZFmGF0fKz1j3VtNJxqsA
110
110
  alita_sdk/runtime/tools/artifact.py,sha256=u3szFwZqguHrPZ3tZJ7S_TiZl7cxlT3oHYd6zbdpRDE,13842
111
111
  alita_sdk/runtime/tools/datasource.py,sha256=pvbaSfI-ThQQnjHG-QhYNSTYRnZB0rYtZFpjCfpzxYI,2443
112
112
  alita_sdk/runtime/tools/echo.py,sha256=spw9eCweXzixJqHnZofHE1yWiSUa04L4VKycf3KCEaM,486
113
- alita_sdk/runtime/tools/function.py,sha256=eTq4em9N1-6CrZ4CZQ4eLZt1kMdY4o7Q3LOUaxzz760,6928
113
+ alita_sdk/runtime/tools/function.py,sha256=4r-VbGtm8gN_RTU2I-1iUNVs_MWNgRqn-aQrr__lCTc,7001
114
114
  alita_sdk/runtime/tools/graph.py,sha256=MbnZYqdmvZY7SGDp43lOVVIjUt5ARHSgj43mdtBjSjQ,3092
115
115
  alita_sdk/runtime/tools/image_generation.py,sha256=8ZH4SoRrbS4EzmtF6cpNMRvuFephCYD2S8uqNC9KGE4,4274
116
116
  alita_sdk/runtime/tools/indexer_tool.py,sha256=whSLPevB4WD6dhh2JDXEivDmTvbjiMV1MrPl9cz5eLA,4375
@@ -134,11 +134,11 @@ alita_sdk/runtime/utils/save_dataframe.py,sha256=i-E1wp-t4wb17Zq3nA3xYwgSILjoXNi
134
134
  alita_sdk/runtime/utils/streamlit.py,sha256=GQ69CsjfRMcGXcCrslL0Uoj24Cl07Jeji0rZxELaKTQ,104930
135
135
  alita_sdk/runtime/utils/toolkit_runtime.py,sha256=MU63Fpxj0b5_r1IUUc0Q3-PN9VwL7rUxp2MRR4tmYR8,5136
136
136
  alita_sdk/runtime/utils/toolkit_utils.py,sha256=I9QFqnaqfVgN26LUr6s3XlBlG6y0CoHURnCzG7XcwVs,5311
137
- alita_sdk/runtime/utils/utils.py,sha256=BVEVLkYiiotcUD0XsHyx-wACpHfALsQg7PLZpObqvK8,1008
137
+ alita_sdk/runtime/utils/utils.py,sha256=PJK8A-JVIzY1IowOjGG8DIqsIiEFe65qDKvFcjJCKWA,1041
138
138
  alita_sdk/tools/__init__.py,sha256=jUj1ztC2FbkIUB-YYmiqaz_rqW7Il5kWzDPn1mJmj5w,10545
139
- alita_sdk/tools/base_indexer_toolkit.py,sha256=_Q8K5fVg5gBFlZ94wYvBrPWJ56VobnNrfr15Knyobu4,26632
139
+ alita_sdk/tools/base_indexer_toolkit.py,sha256=i0S3tIdXrWoRx5B5v0cQMArnmOTsinC9SMLihlEcdxM,26801
140
140
  alita_sdk/tools/code_indexer_toolkit.py,sha256=p3zVnCnQTUf7JUGra9Rl6GEK2W1-hvvz0Xsgz0v0muM,7292
141
- alita_sdk/tools/elitea_base.py,sha256=nV4sNVctJGgLqWTrqkI2iMc07k69GQ6uF5hXrLmsshg,34413
141
+ alita_sdk/tools/elitea_base.py,sha256=34fmVdYgd2YXifU5LFNjMQysr4OOIZ6AOZjq4GxLgSw,34417
142
142
  alita_sdk/tools/non_code_indexer_toolkit.py,sha256=6Lrqor1VeSLbPLDHAfg_7UAUqKFy1r_n6bdsc4-ak98,1315
143
143
  alita_sdk/tools/ado/__init__.py,sha256=NnNYpNFW0_N_v1td_iekYOoQRRB7PIunbpT2f9ZFJM4,1201
144
144
  alita_sdk/tools/ado/utils.py,sha256=PTCludvaQmPLakF2EbCGy66Mro4-rjDtavVP-xcB2Wc,1252
@@ -353,8 +353,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=kT0TbmMvuKhDUZc0i7KO18O38JM9S
353
353
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=0ne8XLJEQSLOWfzd2HdnqOYmQlUliKHbBED5kW_Vias,2895
354
354
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=kmw_xol8YIYFplBLWTqP_VKPRhL_1ItDD0_vXTe_UuI,14906
355
355
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=R371waHsms4sllHCbijKYs90C-9Yu0sSR3N4SUfQOgU,5066
356
- alita_sdk-0.3.377.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
- alita_sdk-0.3.377.dist-info/METADATA,sha256=rUHtuRzi9cHmWrlCZLzi2LfWfbJ-23kMyK7nP2Y3KRs,19071
358
- alita_sdk-0.3.377.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
- alita_sdk-0.3.377.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
- alita_sdk-0.3.377.dist-info/RECORD,,
356
+ alita_sdk-0.3.378.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
+ alita_sdk-0.3.378.dist-info/METADATA,sha256=JZZ0qoXsRM2PriFKAUs4xSabkZkxQm6oX4ZBT57V3OU,19071
358
+ alita_sdk-0.3.378.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
+ alita_sdk-0.3.378.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
+ alita_sdk-0.3.378.dist-info/RECORD,,