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

@@ -348,8 +348,8 @@ class StateModifierNode(Runnable):
348
348
  return result
349
349
 
350
350
 
351
-
352
- def prepare_output_schema(lg_builder, memory, store, debug=False, interrupt_before=None, interrupt_after=None, state_class=None, output_variables=None):
351
+ def prepare_output_schema(lg_builder, memory, store, debug=False, interrupt_before=None, interrupt_after=None,
352
+ state_class=None, output_variables=None):
353
353
  # prepare output channels
354
354
  if interrupt_after is None:
355
355
  interrupt_after = []
@@ -466,7 +466,7 @@ def create_graph(
466
466
  elif node_type == 'agent':
467
467
  input_params = node.get('input', ['messages'])
468
468
  input_mapping = node.get('input_mapping',
469
- {'messages': {'type': 'variable', 'value': 'messages'}})
469
+ {'messages': {'type': 'variable', 'value': 'messages'}})
470
470
  lg_builder.add_node(node_id, FunctionTool(
471
471
  client=client, tool=tool,
472
472
  name=node_id, return_type='str',
@@ -481,7 +481,8 @@ def create_graph(
481
481
  # wrap with mappings
482
482
  pipeline_name = node.get('tool', None)
483
483
  if not pipeline_name:
484
- raise ValueError("Subgraph must have a 'tool' node: add required tool to the subgraph node")
484
+ raise ValueError(
485
+ "Subgraph must have a 'tool' node: add required tool to the subgraph node")
485
486
  node_fn = SubgraphRunnable(
486
487
  inner=tool.graph,
487
488
  name=pipeline_name,
@@ -520,7 +521,8 @@ def create_graph(
520
521
  loop_toolkit_name = node.get('loop_toolkit_name')
521
522
  loop_tool_name = node.get('loop_tool')
522
523
  if (loop_toolkit_name and loop_tool_name) or loop_tool_name:
523
- loop_tool_name = f"{clean_string(loop_toolkit_name)}{TOOLKIT_SPLITTER}{loop_tool_name}" if loop_toolkit_name else clean_string(loop_tool_name)
524
+ loop_tool_name = f"{clean_string(loop_toolkit_name)}{TOOLKIT_SPLITTER}{loop_tool_name}" if loop_toolkit_name else clean_string(
525
+ loop_tool_name)
524
526
  for t in tools:
525
527
  if t.name == loop_tool_name:
526
528
  logger.debug(f"Loop tool discovered: {t}")
@@ -555,7 +557,8 @@ def create_graph(
555
557
  break
556
558
  elif node_type == 'code':
557
559
  from ..tools.sandbox import create_sandbox_tool
558
- sandbox_tool = create_sandbox_tool(stateful=False, allow_net=True, alita_client=kwargs.get('alita_client', None))
560
+ sandbox_tool = create_sandbox_tool(stateful=False, allow_net=True,
561
+ alita_client=kwargs.get('alita_client', None))
559
562
  code_data = node.get('code', {'type': 'fixed', 'value': "return 'Code block is empty'"})
560
563
  lg_builder.add_node(node_id, FunctionTool(
561
564
  tool=sandbox_tool, name=node['id'], return_type='dict',
@@ -777,7 +780,13 @@ class LangGraphAgentRunnable(CompiledStateGraph):
777
780
  # Convert chat history dict messages to LangChain message objects
778
781
  chat_history = input.pop('chat_history')
779
782
  input['messages'] = [convert_dict_to_message(msg) for msg in chat_history]
780
-
783
+
784
+ # handler for LLM node: if no input (Chat perspective), then take last human message
785
+ if not input.get('input'):
786
+ if input.get('messages'):
787
+ input['input'] = [next((msg for msg in reversed(input['messages']) if isinstance(msg, HumanMessage)),
788
+ None)]
789
+
781
790
  # Append current input to existing messages instead of overwriting
782
791
  if input.get('input'):
783
792
  if isinstance(input['input'], str):
@@ -801,7 +810,8 @@ class LangGraphAgentRunnable(CompiledStateGraph):
801
810
  else:
802
811
  result = super().invoke(input, config=config, *args, **kwargs)
803
812
  try:
804
- output = next((msg.content for msg in reversed(result['messages']) if not isinstance(msg, HumanMessage)), result['messages'][-1].content)
813
+ output = next((msg.content for msg in reversed(result['messages']) if not isinstance(msg, HumanMessage)),
814
+ result['messages'][-1].content)
805
815
  except:
806
816
  output = list(result.values())[-1]
807
817
  config_state = self.get_state(config)
@@ -809,8 +819,6 @@ class LangGraphAgentRunnable(CompiledStateGraph):
809
819
  if is_execution_finished:
810
820
  thread_id = None
811
821
 
812
-
813
-
814
822
  result_with_state = {
815
823
  "output": output,
816
824
  "thread_id": thread_id,
@@ -160,6 +160,8 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
160
160
  if clean_index:
161
161
  self._clean_index(index_name)
162
162
  #
163
+ self.index_meta_init(index_name, kwargs)
164
+ #
163
165
  self._log_tool_event(f"Indexing data into collection with suffix '{index_name}'. It can take some time...")
164
166
  self._log_tool_event(f"Loading the documents to index...{kwargs}")
165
167
  documents = self._base_loader(**kwargs)
@@ -454,6 +456,29 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
454
456
  reranking_config=reranking_config,
455
457
  extended_search=extended_search
456
458
  )
459
+
460
+ def index_meta_init(self, index_name: str, index_configuration: dict[str, Any]):
461
+ index_meta = super().get_index_meta(index_name)
462
+ if not index_meta:
463
+ self._log_tool_event(
464
+ f"There is no existing index_meta for collection '{index_name}'. Initializing it.",
465
+ tool_name="index_data"
466
+ )
467
+ from ..runtime.langchain.interfaces.llm_processor import add_documents
468
+ created_on = time.time()
469
+ metadata = {
470
+ "collection": index_name,
471
+ "type": IndexerKeywords.INDEX_META_TYPE.value,
472
+ "indexed": 0,
473
+ "state": IndexerKeywords.INDEX_META_IN_PROGRESS.value,
474
+ "index_configuration": index_configuration,
475
+ "created_on": created_on,
476
+ "updated_on": created_on,
477
+ "history": "[]",
478
+ "task_id": None,
479
+ }
480
+ index_meta_doc = Document(page_content=f"{IndexerKeywords.INDEX_META_TYPE.value}_{index_name}", metadata=metadata)
481
+ add_documents(vectorstore=self.vectorstore, documents=[index_meta_doc])
457
482
 
458
483
  def index_meta_update(self, index_name: str, state: str, result: int):
459
484
  index_meta_raw = super().get_index_meta(index_name)
@@ -3,6 +3,7 @@ from typing import Optional, List
3
3
  from logging import getLogger
4
4
 
5
5
  import requests
6
+ from langchain_core.documents import Document
6
7
 
7
8
  logger = getLogger(__name__)
8
9
  from PIL import Image
@@ -193,6 +194,15 @@ class AlitaConfluenceLoader(ConfluenceLoader):
193
194
  else:
194
195
  return super().process_image(link, ocr_languages)
195
196
 
197
+ def process_page(self, page: dict, include_attachments: bool, include_comments: bool, include_labels: bool,
198
+ content_format: ContentFormat, ocr_languages: Optional[str] = None,
199
+ keep_markdown_format: Optional[bool] = False, keep_newlines: bool = False) -> Document:
200
+ if not page.get("title"):
201
+ # if 'include_restricted_content' set to True, draft pages are loaded and can have no title
202
+ page["title"] = "Untitled"
203
+ return super().process_page(page, include_attachments, include_comments, include_labels, content_format,
204
+ ocr_languages, keep_markdown_format, keep_newlines)
205
+
196
206
  # TODO review usage
197
207
  # def process_svg(
198
208
  # self,
@@ -136,7 +136,15 @@ class PGVectorAdapter(VectorStoreAdapter):
136
136
  """Clean the vectorstore collection by deleting all indexed data."""
137
137
  # This logic deletes all data from the vectorstore collection without removal of collection.
138
138
  # Collection itself remains available for future indexing.
139
- vectorstore_wrapper.vectorstore.delete(ids=self.get_indexed_ids(vectorstore_wrapper, index_name))
139
+ from sqlalchemy.orm import Session
140
+ from sqlalchemy import func
141
+
142
+ store = vectorstore_wrapper.vectorstore
143
+ with Session(store.session_maker.bind) as session:
144
+ session.query(store.EmbeddingStore).filter(
145
+ func.jsonb_extract_path_text(store.EmbeddingStore.cmetadata, 'collection') == index_name
146
+ ).delete(synchronize_session=False)
147
+ session.commit()
140
148
 
141
149
  def is_vectorstore_type(self, vectorstore) -> bool:
142
150
  """Check if the vectorstore is a PGVector store."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.392
3
+ Version: 0.3.393
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,7 +45,7 @@ alita_sdk/runtime/langchain/assistant.py,sha256=ssgiRln0ZpPSjStqitTKj-EaSlsh5F6A
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=p9okbdkZhG4qY0GHNm4PL6ZGQwVw-enWyoEPB_FKsDg,48706
48
+ alita_sdk/runtime/langchain/langraph_agent.py,sha256=gYL1m1WzN9dT-2m2gpA3b2IxGXOk1ytEbDVxuqyCrzU,49204
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
@@ -136,7 +136,7 @@ alita_sdk/runtime/utils/toolkit_runtime.py,sha256=MU63Fpxj0b5_r1IUUc0Q3-PN9VwL7r
136
136
  alita_sdk/runtime/utils/toolkit_utils.py,sha256=I9QFqnaqfVgN26LUr6s3XlBlG6y0CoHURnCzG7XcwVs,5311
137
137
  alita_sdk/runtime/utils/utils.py,sha256=PJK8A-JVIzY1IowOjGG8DIqsIiEFe65qDKvFcjJCKWA,1041
138
138
  alita_sdk/tools/__init__.py,sha256=NrZyTEdEhmO1NnAR9RFMQ05Mb-kgu68mAQz3n5r0HYs,10692
139
- alita_sdk/tools/base_indexer_toolkit.py,sha256=mgl2Uc0xkRlkuA_fx-qvtO0LO8gRrCvJQUdtedzSkys,25224
139
+ alita_sdk/tools/base_indexer_toolkit.py,sha256=JZR69D-ABZZEIE5I5LzthqM9-2xwLvuQPtLC3UYIPeE,26437
140
140
  alita_sdk/tools/code_indexer_toolkit.py,sha256=p3zVnCnQTUf7JUGra9Rl6GEK2W1-hvvz0Xsgz0v0muM,7292
141
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
@@ -232,7 +232,7 @@ alita_sdk/tools/code/sonar/__init__.py,sha256=iPqj2PnUY4-btJjaDeWIPdn-c9L_uCr_qO
232
232
  alita_sdk/tools/code/sonar/api_wrapper.py,sha256=nNqxcWN_6W8c0ckj-Er9HkNuAdgQLoWBXh5UyzNutis,2653
233
233
  alita_sdk/tools/confluence/__init__.py,sha256=zRnPBM1c7VTRTS955HNc7AEGV5t8ACc2f9wBXmmeXao,6845
234
234
  alita_sdk/tools/confluence/api_wrapper.py,sha256=TrB4g0gYlollej9kG68kQXrrOUiFwVUxYKo-tZ4ngac,90719
235
- alita_sdk/tools/confluence/loader.py,sha256=4bf5qrJMEiJzuZp2NlxO2XObLD1w7fxss_WyMUpe8sg,9290
235
+ alita_sdk/tools/confluence/loader.py,sha256=xJhV80zM4x_oalwe36UqiEf4GOgCm_XEezLQNKj4j4k,10025
236
236
  alita_sdk/tools/confluence/utils.py,sha256=Lxo6dBD0OlvM4o0JuK6qeB_4LV9BptiwJA9e1vqNcDw,435
237
237
  alita_sdk/tools/custom_open_api/__init__.py,sha256=9aT5SPNPWcJC6jMZEM-3rUCXVULj_3-qJLQKmnreKNo,2537
238
238
  alita_sdk/tools/custom_open_api/api_wrapper.py,sha256=sDSFpvEqpSvXHGiBISdQQcUecfO3md-_F8hAi6p2dvg,4340
@@ -332,7 +332,7 @@ alita_sdk/tools/testrail/api_wrapper.py,sha256=tQcGlFJmftvs5ZiO4tsP19fCo4CrJeq_U
332
332
  alita_sdk/tools/utils/__init__.py,sha256=xB9OQgW65DftadrSpoAAitnEIbIXZKBOCji0NDe7FRM,3923
333
333
  alita_sdk/tools/utils/available_tools_decorator.py,sha256=IbrdfeQkswxUFgvvN7-dyLMZMyXLiwvX7kgi3phciCk,273
334
334
  alita_sdk/tools/utils/content_parser.py,sha256=7ohj8HeL_-rmc-Fv0TS8IpxIQC8tOpfuhyT3XlWx-gQ,15368
335
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py,sha256=I7YCDT2qslXmiUzDAzaUEN1gCy8DJ5RcUAipl3ISzA0,19403
335
+ alita_sdk/tools/vector_adapters/VectorStoreAdapter.py,sha256=-9ByRh8bVRraTcJPS7SE-2l3en6A4UkKGS9iAd9fa3w,19722
336
336
  alita_sdk/tools/vector_adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
337
337
  alita_sdk/tools/xray/__init__.py,sha256=eOMWP8VamFbbJgt1xrGpGPqB9ByOTA0Cd3LCaETzGk4,4376
338
338
  alita_sdk/tools/xray/api_wrapper.py,sha256=uj5kzUgPdo_Oct9WCNMOpkb6o_3L7J4LZrEGtrwYMmc,30157
@@ -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.392.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
- alita_sdk-0.3.392.dist-info/METADATA,sha256=zU605qkaYYtpcH3eynsv5q72sw6tofJq_SPcqIjS0qI,19071
358
- alita_sdk-0.3.392.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
- alita_sdk-0.3.392.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
- alita_sdk-0.3.392.dist-info/RECORD,,
356
+ alita_sdk-0.3.393.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
+ alita_sdk-0.3.393.dist-info/METADATA,sha256=EGvHTl8vdFizOdKbiJOld6GmaybBT3SAazljqzu_tOk,19071
358
+ alita_sdk-0.3.393.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
+ alita_sdk-0.3.393.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
+ alita_sdk-0.3.393.dist-info/RECORD,,