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

@@ -47,8 +47,8 @@ def formulate_query(kwargs):
47
47
 
48
48
 
49
49
  class GraphTool(BaseTool):
50
- name: str
51
- description: str
50
+ name: str = 'GraphTool'
51
+ description: str = 'Graph tool for tools'
52
52
  graph: CompiledStateGraph
53
53
  args_schema: Type[BaseModel] = graphToolSchema
54
54
  return_type: str = "str"
@@ -65,10 +65,16 @@ class GraphTool(BaseTool):
65
65
  all_kwargs = {**kwargs, **extras, **schema_values}
66
66
  if config is None:
67
67
  config = {}
68
- return self._run(*config, **all_kwargs)
68
+ # Pass the config to the _run empty or the one passed from the parent executor.
69
+ return self._run(config, **all_kwargs)
69
70
 
70
71
  def _run(self, *args, **kwargs):
71
- response = self.graph.invoke(formulate_query(kwargs))
72
+ config = None
73
+ # From invoke method we are passing only 1 arg so it is safe to do this condition and config assignment.
74
+ # Default to None is safe because it will be checked also on the langchain side.
75
+ if args:
76
+ config = args[0]
77
+ response = self.graph.invoke(formulate_query(kwargs), config=config)
72
78
  if self.return_type == "str":
73
79
  return response["output"]
74
80
  else:
@@ -177,7 +177,9 @@ class LLMNode(BaseTool):
177
177
  if tool_to_execute:
178
178
  try:
179
179
  logger.info(f"Executing tool '{tool_name}' with args: {tool_args}")
180
- tool_result = tool_to_execute.invoke(tool_args)
180
+ # Pass the underlying config to the tool execution invoke method
181
+ # since it may be another agent, graph, etc. to see it properly in thinking steps
182
+ tool_result = tool_to_execute.invoke(tool_args, config=config)
181
183
 
182
184
  # Create tool message with result - preserve structured content
183
185
  from langchain_core.messages import ToolMessage
@@ -161,8 +161,6 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
161
161
  if clean_index:
162
162
  self._clean_index(index_name)
163
163
  #
164
- self.index_meta_init(index_name, kwargs)
165
- #
166
164
  self._log_tool_event(f"Indexing data into collection with suffix '{index_name}'. It can take some time...")
167
165
  self._log_tool_event(f"Loading the documents to index...{kwargs}")
168
166
  documents = self._base_loader(**kwargs)
@@ -455,39 +453,6 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
455
453
  reranking_config=reranking_config,
456
454
  extended_search=extended_search
457
455
  )
458
-
459
- def index_meta_init(self, index_name: str, index_configuration: dict[str, Any]):
460
- index_meta_raw = super().get_index_meta(index_name)
461
- from ..runtime.langchain.interfaces.llm_processor import add_documents
462
- created_on = time.time()
463
- metadata = {
464
- "collection": index_name,
465
- "type": IndexerKeywords.INDEX_META_TYPE.value,
466
- "indexed": 0,
467
- "state": IndexerKeywords.INDEX_META_IN_PROGRESS.value,
468
- "index_configuration": index_configuration,
469
- "created_on": created_on,
470
- "updated_on": created_on,
471
- "history": "[]",
472
- }
473
- index_meta_ids = None
474
- #
475
- if index_meta_raw:
476
- history_raw = index_meta_raw.get("metadata", {}).get("history", "[]")
477
- if isinstance(history_raw, str) and history_raw.strip():
478
- try:
479
- history = json.loads(history_raw)
480
- except (json.JSONDecodeError, TypeError):
481
- history = []
482
- else:
483
- history = []
484
- new_history_item = {k: v for k, v in index_meta_raw.get("metadata", {}).items() if k != "history"}
485
- history.append(new_history_item)
486
- metadata["history"] = json.dumps(history)
487
- index_meta_ids = [index_meta_raw.get("id")]
488
- #
489
- index_meta_doc = Document(page_content=f"{IndexerKeywords.INDEX_META_TYPE.value}_{index_name}", metadata=metadata)
490
- add_documents(vectorstore=self.vectorstore, documents=[index_meta_doc], ids=index_meta_ids)
491
456
 
492
457
  def index_meta_update(self, index_name: str, state: str, result: int):
493
458
  index_meta_raw = super().get_index_meta(index_name)
@@ -7,12 +7,14 @@ from json import JSONDecodeError
7
7
  from typing import Optional, List, Any, Dict, Callable, Generator, Literal
8
8
 
9
9
  import requests
10
+ from atlassian.errors import ApiError
10
11
  from langchain_community.document_loaders.confluence import ContentFormat
11
12
  from langchain_core.documents import Document
12
13
  from langchain_core.messages import HumanMessage
13
14
  from langchain_core.tools import ToolException
14
15
  from markdownify import markdownify
15
16
  from pydantic import Field, PrivateAttr, model_validator, create_model, SecretStr
17
+ from requests import HTTPError
16
18
  from tenacity import retry, stop_after_attempt, wait_exponential, before_sleep_log
17
19
 
18
20
  from alita_sdk.tools.non_code_indexer_toolkit import NonCodeIndexerToolkit
@@ -194,6 +196,7 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
194
196
  keep_markdown_format: Optional[bool] = True
195
197
  ocr_languages: Optional[str] = None
196
198
  keep_newlines: Optional[bool] = True
199
+ _errors: Optional[list[str]] = None
197
200
  _image_cache: ImageDescriptionCache = PrivateAttr(default_factory=ImageDescriptionCache)
198
201
 
199
202
  @model_validator(mode='before')
@@ -498,7 +501,9 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
498
501
  restrictions = self.client.get_all_restrictions_for_content(page["id"])
499
502
 
500
503
  return (
501
- page["status"] == "current"
504
+ (page["status"] == "current"
505
+ # allow user to see archived content if needed
506
+ or page["status"] == "archived")
502
507
  and not restrictions["read"]["restrictions"]["user"]["results"]
503
508
  and not restrictions["read"]["restrictions"]["group"]["results"]
504
509
  )
@@ -518,18 +523,34 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
518
523
  ),
519
524
  before_sleep=before_sleep_log(logger, logging.WARNING),
520
525
  )(self.client.get_page_by_id)
521
- page = get_page(
522
- page_id=page_id, expand=f"{self.content_format.value},version"
523
- )
526
+ try:
527
+ page = get_page(
528
+ page_id=page_id, expand=f"{self.content_format.value},version"
529
+ )
530
+ except (ApiError, HTTPError) as e:
531
+ logger.error(f"Error fetching page with ID {page_id}: {e}")
532
+ page_content_temp = f"Confluence API Error: cannot fetch the page with ID {page_id}: {e}"
533
+ # store errors
534
+ if self._errors is None:
535
+ self._errors = []
536
+ self._errors.append(page_content_temp)
537
+ return Document(page_content=page_content_temp,
538
+ metadata={})
524
539
  if not self.include_restricted_content and not self.is_public_page(page):
525
540
  continue
526
541
  yield self.process_page(page, skip_images)
527
542
 
543
+ def _log_errors(self):
544
+ """ Log errors encountered during toolkit execution. """
545
+ if self._errors:
546
+ logger.info(f"Errors encountered during toolkit execution: {self._errors}")
547
+
528
548
  def read_page_by_id(self, page_id: str, skip_images: bool = False):
529
549
  """Reads a page by its id in the Confluence space. If id is not available, but there is a title - use get_page_id first."""
530
550
  result = list(self.get_pages_by_id([page_id], skip_images))
531
551
  if not result:
532
- "Page not found"
552
+ return f"Pages not found. Errors: {self._errors}" if self._errors \
553
+ else "Pages not found or you do not have access to them."
533
554
  return result[0].page_content
534
555
  # return self._strip_base64_images(result[0].page_content) if skip_images else result[0].page_content
535
556
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.379
3
+ Version: 0.3.381
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
@@ -111,10 +111,10 @@ alita_sdk/runtime/tools/artifact.py,sha256=u3szFwZqguHrPZ3tZJ7S_TiZl7cxlT3oHYd6z
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
113
  alita_sdk/runtime/tools/function.py,sha256=4r-VbGtm8gN_RTU2I-1iUNVs_MWNgRqn-aQrr__lCTc,7001
114
- alita_sdk/runtime/tools/graph.py,sha256=MbnZYqdmvZY7SGDp43lOVVIjUt5ARHSgj43mdtBjSjQ,3092
114
+ alita_sdk/runtime/tools/graph.py,sha256=7jImBBSEdP5Mjnn2keOiyUwdGDFhEXLUrgUiugO3mgA,3503
115
115
  alita_sdk/runtime/tools/image_generation.py,sha256=8ZH4SoRrbS4EzmtF6cpNMRvuFephCYD2S8uqNC9KGE4,4274
116
116
  alita_sdk/runtime/tools/indexer_tool.py,sha256=whSLPevB4WD6dhh2JDXEivDmTvbjiMV1MrPl9cz5eLA,4375
117
- alita_sdk/runtime/tools/llm.py,sha256=YDb0kIu3QCiv2DkgpnFv5-pbAor6CMQ5IcYnyVMQrtY,15142
117
+ alita_sdk/runtime/tools/llm.py,sha256=AOxC3OEQ8FQCiI6f1we6s_X3a7DGyd2Z6yi1P_1jqoY,15376
118
118
  alita_sdk/runtime/tools/loop.py,sha256=uds0WhZvwMxDVFI6MZHrcmMle637cQfBNg682iLxoJA,8335
119
119
  alita_sdk/runtime/tools/loop_output.py,sha256=U4hO9PCQgWlXwOq6jdmCGbegtAxGAPXObSxZQ3z38uk,8069
120
120
  alita_sdk/runtime/tools/mcp_server_tool.py,sha256=MhLxZJ44LYrB_0GrojmkyqKoDRaqIHkEQAsg718ipog,4277
@@ -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=i0S3tIdXrWoRx5B5v0cQMArnmOTsinC9SMLihlEcdxM,26801
139
+ alita_sdk/tools/base_indexer_toolkit.py,sha256=UcqfJ8lncvlCFBhbzgmtnKQxUL--2NIYg-b7Hr2CuyY,25160
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
@@ -231,7 +231,7 @@ alita_sdk/tools/code/loaders/codesearcher.py,sha256=XoXXZtIQZhvjIwZlnl_4wVGHC-3s
231
231
  alita_sdk/tools/code/sonar/__init__.py,sha256=iPqj2PnUY4-btJjaDeWIPdn-c9L_uCr_qOoP_uwRoXw,3360
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
- alita_sdk/tools/confluence/api_wrapper.py,sha256=1HZftLQFzpNwGSN-9LPp8RQr1X-0fsKzmFlc-WEadZU,89545
234
+ alita_sdk/tools/confluence/api_wrapper.py,sha256=5U6GIO65o0WoS_4f-Rci3n6CsCh4TGeXJNWzgj2iLEI,90631
235
235
  alita_sdk/tools/confluence/loader.py,sha256=4bf5qrJMEiJzuZp2NlxO2XObLD1w7fxss_WyMUpe8sg,9290
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
@@ -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.379.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
- alita_sdk-0.3.379.dist-info/METADATA,sha256=3ZAbyIgfi1p802VDdfvzPvuPiZ5o8RyiTGIAbkIR1Yk,19071
358
- alita_sdk-0.3.379.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
- alita_sdk-0.3.379.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
- alita_sdk-0.3.379.dist-info/RECORD,,
356
+ alita_sdk-0.3.381.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
357
+ alita_sdk-0.3.381.dist-info/METADATA,sha256=r5jD9tROs_Vut2MsGp7MwKJL8GlB394ujtWQIfWnp20,19071
358
+ alita_sdk-0.3.381.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
359
+ alita_sdk-0.3.381.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
360
+ alita_sdk-0.3.381.dist-info/RECORD,,