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

@@ -111,7 +111,10 @@ class Assistant:
111
111
  messages.extend(chat_history)
112
112
  self.prompt = Jinja2TemplatedChatMessagesTemplate(messages=messages)
113
113
  if input_variables:
114
- self.prompt.input_variables = input_variables
114
+ if hasattr(self.prompt, 'input_variables') and self.prompt.input_variables is not None:
115
+ self.prompt.input_variables.extend(input_variables)
116
+ else:
117
+ self.prompt.input_variables = input_variables
115
118
  if variables:
116
119
  self.prompt.partial_variables = variables
117
120
  try:
@@ -786,13 +786,6 @@ class LangGraphAgentRunnable(CompiledStateGraph):
786
786
  else:
787
787
  result = super().invoke(input, config=config, *args, **kwargs)
788
788
  try:
789
- # if self.output_variables and self.output_variables[0] != "messages":
790
- # # If output_variables are specified, use the value of first one or use the last messages as default
791
- # output = result.get(self.output_variables[0])
792
- # if not output:
793
- # output = result['messages'][-1].content
794
- # else:
795
- # output = result['messages'][-1].content
796
789
  output = next((msg.content for msg in reversed(result['messages']) if not isinstance(msg, HumanMessage)), result['messages'][-1].content)
797
790
  except:
798
791
  output = list(result.values())[-1]
@@ -6,6 +6,8 @@ from typing import Any, Optional, List, Dict, Generator
6
6
 
7
7
  from langchain_core.documents import Document
8
8
  from langchain_core.messages import HumanMessage
9
+ from langchain_core.tools import ToolException
10
+ from psycopg.errors import DataException
9
11
  from pydantic import BaseModel, model_validator, Field
10
12
 
11
13
  from alita_sdk.tools.elitea_base import BaseToolApiWrapper
@@ -316,6 +318,15 @@ class VectorStoreWrapperBase(BaseToolApiWrapper):
316
318
  if doc_id not in unique_docs or score > chunk_type_scores.get(doc_id, 0):
317
319
  unique_docs[doc_id] = doc
318
320
  chunk_type_scores[doc_id] = score
321
+ except DataException as dimException:
322
+ exception_str = str(dimException)
323
+ if 'different vector dimensions' in exception_str:
324
+ logger.error(f"Data exception: {exception_str}")
325
+ raise ToolException(f"Global search cannot be completed since collections were indexed using "
326
+ f"different embedding models. Use search within a single collection."
327
+ f"\nDetails: {exception_str}")
328
+ raise ToolException(f"Data exception during search. Possibly invalid filter: {exception_str}")
329
+
319
330
  except Exception as e:
320
331
  logger.warning(f"Error searching for document chunks: {str(e)}")
321
332
 
@@ -366,15 +366,15 @@ class BaseIndexerToolkit(VectorStoreWrapperBase):
366
366
  filter.update({"collection": {
367
367
  "$eq": collection_suffix.strip()
368
368
  }})
369
- filter = {
370
- "$and": [
371
- filter,
372
- {"$or": [
373
- {"type": {"$exists": False}},
374
- {"type": {"$ne": IndexerKeywords.INDEX_META_TYPE.value}}
375
- ]},
376
- ]
377
- }
369
+ filter = {
370
+ "$and": [
371
+ filter,
372
+ {"$or": [
373
+ {"type": {"$exists": False}},
374
+ {"type": {"$ne": IndexerKeywords.INDEX_META_TYPE.value}}
375
+ ]},
376
+ ]
377
+ }
378
378
  return filter
379
379
 
380
380
  def index_meta_read(self):
@@ -815,6 +815,10 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
815
815
  from .loader import AlitaConfluenceLoader
816
816
  from copy import copy
817
817
  content_format = kwargs.get('content_format', 'view').lower()
818
+
819
+ self._index_include_attachments = kwargs.get('include_attachments', False)
820
+ self._include_extensions = kwargs.get('include_extensions', [])
821
+ self._skip_extensions = kwargs.get('skip_extensions', [])
818
822
  base_params = {
819
823
  'url': self.base_url,
820
824
  'space_key': self.space,
@@ -847,65 +851,79 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
847
851
 
848
852
  def _process_document(self, document: Document) -> Generator[Document, None, None]:
849
853
  try:
850
- page_id = document.metadata.get('id')
851
- attachments = self.client.get_attachments_from_content(page_id)
852
- if not attachments or not attachments.get('results'):
853
- return f"No attachments found for page ID {page_id}."
854
-
855
- # Get attachment history for created/updated info
856
- history_map = {}
857
- for attachment in attachments['results']:
858
- try:
859
- hist = self.client.history(attachment['id'])
860
- history_map[attachment['id']] = hist
861
- except Exception as e:
862
- logger.warning(f"Failed to fetch history for attachment {attachment.get('title', '')}: {str(e)}")
863
- history_map[attachment['id']] = None
864
-
865
- import re
866
- for attachment in attachments['results']:
867
- title = attachment.get('title', '')
868
- file_ext = title.lower().split('.')[-1] if '.' in title else ''
869
-
870
- media_type = attachment.get('metadata', {}).get('mediaType', '')
871
- # Core metadata extraction with history
872
- hist = history_map.get(attachment['id']) or {}
873
- created_by = hist.get('createdBy', {}).get('displayName', '') if hist else attachment.get('creator', {}).get('displayName', '')
874
- created_date = hist.get('createdDate', '') if hist else attachment.get('created', '')
875
- last_updated = hist.get('lastUpdated', {}).get('when', '') if hist else ''
854
+ if self._index_include_attachments:
855
+ page_id = document.metadata.get('id')
856
+ attachments = self.client.get_attachments_from_content(page_id)
857
+ if not attachments or not attachments.get('results'):
858
+ return f"No attachments found for page ID {page_id}."
859
+
860
+ # Get attachment history for created/updated info
861
+ history_map = {}
862
+ for attachment in attachments['results']:
863
+ try:
864
+ hist = self.client.history(attachment['id'])
865
+ history_map[attachment['id']] = hist
866
+ except Exception as e:
867
+ logger.warning(f"Failed to fetch history for attachment {attachment.get('title', '')}: {str(e)}")
868
+ history_map[attachment['id']] = None
869
+
870
+ import re
871
+ for attachment in attachments['results']:
872
+ title = attachment.get('title', '')
873
+ file_ext = title.lower().split('.')[-1] if '.' in title else ''
874
+
875
+ # Re-verify extension filters
876
+ # Check if file should be skipped based on skip_extensions
877
+ if any(re.match(pattern.replace('*', '.*') + '$', title, re.IGNORECASE)
878
+ for pattern in self._skip_extensions):
879
+ continue
880
+
881
+ # Check if file should be included based on include_extensions
882
+ # If include_extensions is empty, process all files (that weren't skipped)
883
+ if self._include_extensions and not (
884
+ any(re.match(pattern.replace('*', '.*') + '$', title, re.IGNORECASE)
885
+ for pattern in self._include_extensions)):
886
+ continue
887
+
888
+ media_type = attachment.get('metadata', {}).get('mediaType', '')
889
+ # Core metadata extraction with history
890
+ hist = history_map.get(attachment['id']) or {}
891
+ created_by = hist.get('createdBy', {}).get('displayName', '') if hist else attachment.get('creator', {}).get('displayName', '')
892
+ created_date = hist.get('createdDate', '') if hist else attachment.get('created', '')
893
+ last_updated = hist.get('lastUpdated', {}).get('when', '') if hist else ''
894
+
895
+ metadata = {
896
+ 'name': title,
897
+ 'size': attachment.get('extensions', {}).get('fileSize', None),
898
+ 'creator': created_by,
899
+ 'created': created_date,
900
+ 'updated': last_updated,
901
+ 'media_type': media_type,
902
+ 'labels': [label['name'] for label in
903
+ attachment.get('metadata', {}).get('labels', {}).get('results', [])],
904
+ 'download_url': self.base_url.rstrip('/') + attachment['_links']['download'] if attachment.get(
905
+ '_links', {}).get('download') else None
906
+ }
876
907
 
877
- metadata = {
878
- 'name': title,
879
- 'size': attachment.get('extensions', {}).get('fileSize', None),
880
- 'creator': created_by,
881
- 'created': created_date,
882
- 'updated': last_updated,
883
- 'media_type': media_type,
884
- 'labels': [label['name'] for label in
885
- attachment.get('metadata', {}).get('labels', {}).get('results', [])],
886
- 'download_url': self.base_url.rstrip('/') + attachment['_links']['download'] if attachment.get(
887
- '_links', {}).get('download') else None
888
- }
908
+ download_url = self.base_url.rstrip('/') + attachment['_links']['download']
889
909
 
890
- download_url = self.base_url.rstrip('/') + attachment['_links']['download']
910
+ try:
911
+ resp = self.client.request(method="GET", path=download_url[len(self.base_url):], advanced_mode=True)
912
+ if resp.status_code == 200:
913
+ content = resp.content
914
+ else:
915
+ content = f"[Failed to download {download_url}: HTTP status code {resp.status_code}]"
916
+ except Exception as e:
917
+ content = f"[Error downloading content: {str(e)}]"
891
918
 
892
- try:
893
- resp = self.client.request(method="GET", path=download_url[len(self.base_url):], advanced_mode=True)
894
- if resp.status_code == 200:
895
- content = resp.content
919
+ if isinstance(content, str):
920
+ yield Document(page_content=content, metadata=metadata)
896
921
  else:
897
- content = f"[Failed to download {download_url}: HTTP status code {resp.status_code}]"
898
- except Exception as e:
899
- content = f"[Error downloading content: {str(e)}]"
900
-
901
- if isinstance(content, str):
902
- yield Document(page_content=content, metadata=metadata)
903
- else:
904
- yield Document(page_content="", metadata={
905
- **metadata,
906
- IndexerKeywords.CONTENT_FILE_NAME.value: f".{file_ext}",
907
- IndexerKeywords.CONTENT_IN_BYTES.value: content
908
- })
922
+ yield Document(page_content="", metadata={
923
+ **metadata,
924
+ IndexerKeywords.CONTENT_FILE_NAME.value: f".{file_ext}",
925
+ IndexerKeywords.CONTENT_IN_BYTES.value: content
926
+ })
909
927
  except Exception as e:
910
928
  yield from ()
911
929
 
@@ -1648,6 +1666,13 @@ class ConfluenceAPIWrapper(NonCodeIndexerToolkit):
1648
1666
  "include_restricted_content": (Optional[bool], Field(description="Include restricted content.", default=False)),
1649
1667
  "include_archived_content": (Optional[bool], Field(description="Include archived content.", default=False)),
1650
1668
  "include_attachments": (Optional[bool], Field(description="Include attachments.", default=False)),
1669
+ 'include_extensions': (Optional[List[str]], Field(
1670
+ description="List of file extensions to include when processing attachments: i.e. ['*.png', '*.jpg']. "
1671
+ "If empty, all files will be processed (except skip_extensions).",
1672
+ default=[])),
1673
+ 'skip_extensions': (Optional[List[str]], Field(
1674
+ description="List of file extensions to skip when processing attachments: i.e. ['*.png', '*.jpg']",
1675
+ default=[])),
1651
1676
  "include_comments": (Optional[bool], Field(description="Include comments.", default=False)),
1652
1677
  "include_labels": (Optional[bool], Field(description="Include labels.", default=True)),
1653
1678
  "ocr_languages": (Optional[str], Field(description="OCR languages for processing attachments.", default='eng')),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.368
3
+ Version: 0.3.370
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
@@ -40,11 +40,11 @@ alita_sdk/runtime/clients/client.py,sha256=BIF6QSnhlTfsTQ_dQs-QZjeBJHZsOtSuv_q7_
40
40
  alita_sdk/runtime/clients/datasource.py,sha256=HAZovoQN9jBg0_-lIlGBQzb4FJdczPhkHehAiVG3Wx0,1020
41
41
  alita_sdk/runtime/clients/prompt.py,sha256=li1RG9eBwgNK_Qf0qUaZ8QNTmsncFrAL2pv3kbxZRZg,1447
42
42
  alita_sdk/runtime/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- alita_sdk/runtime/langchain/assistant.py,sha256=2tH8je9uKegIIIZUuiGU4zqRVg7jyQas8ftkwx01qWw,15224
43
+ alita_sdk/runtime/langchain/assistant.py,sha256=AKZ7LyYHrkwA3F987NgemHhrWAlZk18qt4N85CxqFyU,15426
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=NvoaAZLgb-gcRv14LnZHBFajWHTbimx6QJ9EyOaomoE,48207
47
+ alita_sdk/runtime/langchain/langraph_agent.py,sha256=oJg-k2wWfaa77zjG5Uvcw8CtXUZXbgbSjvRNjIIT84g,47769
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
@@ -123,7 +123,7 @@ alita_sdk/runtime/tools/router.py,sha256=p7e0tX6YAWw2M2Nq0A_xqw1E2P-Xz1DaJvhUstf
123
123
  alita_sdk/runtime/tools/sandbox.py,sha256=WNz-aUMtkGCPg84dDy_0BPkyp-6YjoYB-xjIEFFrtKw,11601
124
124
  alita_sdk/runtime/tools/tool.py,sha256=lE1hGi6qOAXG7qxtqxarD_XMQqTghdywf261DZawwno,5631
125
125
  alita_sdk/runtime/tools/vectorstore.py,sha256=8vRhi1lGFEs3unvnflEi2p59U2MfV32lStpEizpDms0,34467
126
- alita_sdk/runtime/tools/vectorstore_base.py,sha256=4POq0NZ8FnMANop2JweeRNK9ViWcrpBM1y4Jl22E46E,26801
126
+ alita_sdk/runtime/tools/vectorstore_base.py,sha256=1DYmMQEBMLetxQgi6D9Wd_vM_xVCa9qGTAfLOo2kNC0,27533
127
127
  alita_sdk/runtime/utils/AlitaCallback.py,sha256=E4LlSBuCHWiUq6W7IZExERHZY0qcmdjzc_rJlF2iQIw,7356
128
128
  alita_sdk/runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
129
  alita_sdk/runtime/utils/constants.py,sha256=Xntx1b_uxUzT4clwqHA_U6K8y5bBqf_4lSQwXdcWrp4,13586
@@ -135,7 +135,7 @@ alita_sdk/runtime/utils/toolkit_runtime.py,sha256=MU63Fpxj0b5_r1IUUc0Q3-PN9VwL7r
135
135
  alita_sdk/runtime/utils/toolkit_utils.py,sha256=I9QFqnaqfVgN26LUr6s3XlBlG6y0CoHURnCzG7XcwVs,5311
136
136
  alita_sdk/runtime/utils/utils.py,sha256=BVEVLkYiiotcUD0XsHyx-wACpHfALsQg7PLZpObqvK8,1008
137
137
  alita_sdk/tools/__init__.py,sha256=jUj1ztC2FbkIUB-YYmiqaz_rqW7Il5kWzDPn1mJmj5w,10545
138
- alita_sdk/tools/base_indexer_toolkit.py,sha256=dOdl-n_TUCryYCVuCNNyGYN3fwTQuLjNTMTU5axwzW8,26101
138
+ alita_sdk/tools/base_indexer_toolkit.py,sha256=jaUzLqzGwY0YJ4ZGeRHfyrWOiuTpOawUqGrLVqXHtFo,26137
139
139
  alita_sdk/tools/code_indexer_toolkit.py,sha256=6QvI1by0OFdnKTx5TfNoDJjnMrvnTi9T56xaDxzeleU,7306
140
140
  alita_sdk/tools/elitea_base.py,sha256=up3HshASSDfjlHV_HPrs1aD4JIwwX0Ug26WGTzgIYvY,34724
141
141
  alita_sdk/tools/non_code_indexer_toolkit.py,sha256=B3QvhpT1F9QidkCcsOi3J_QrTOaNlTxqWFwe90VivQQ,1329
@@ -230,7 +230,7 @@ alita_sdk/tools/code/loaders/codesearcher.py,sha256=XoXXZtIQZhvjIwZlnl_4wVGHC-3s
230
230
  alita_sdk/tools/code/sonar/__init__.py,sha256=iPqj2PnUY4-btJjaDeWIPdn-c9L_uCr_qOoP_uwRoXw,3360
231
231
  alita_sdk/tools/code/sonar/api_wrapper.py,sha256=nNqxcWN_6W8c0ckj-Er9HkNuAdgQLoWBXh5UyzNutis,2653
232
232
  alita_sdk/tools/confluence/__init__.py,sha256=zRnPBM1c7VTRTS955HNc7AEGV5t8ACc2f9wBXmmeXao,6845
233
- alita_sdk/tools/confluence/api_wrapper.py,sha256=lUhGzcvYgTXx1bYr2lgK5t2lZFrnTWF4PJ_CWT8q-Ao,87805
233
+ alita_sdk/tools/confluence/api_wrapper.py,sha256=cHIr0EnXZVGQMepcaIcFgMfyTKjlkKGbAd0z79pf-bo,89544
234
234
  alita_sdk/tools/confluence/loader.py,sha256=4bf5qrJMEiJzuZp2NlxO2XObLD1w7fxss_WyMUpe8sg,9290
235
235
  alita_sdk/tools/confluence/utils.py,sha256=Lxo6dBD0OlvM4o0JuK6qeB_4LV9BptiwJA9e1vqNcDw,435
236
236
  alita_sdk/tools/custom_open_api/__init__.py,sha256=9aT5SPNPWcJC6jMZEM-3rUCXVULj_3-qJLQKmnreKNo,2537
@@ -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.368.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
- alita_sdk-0.3.368.dist-info/METADATA,sha256=D_3Xrhff7tC9ezLl5uIYNB2gf32WvzqdvJJIJb8KeZ8,19071
357
- alita_sdk-0.3.368.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
- alita_sdk-0.3.368.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
- alita_sdk-0.3.368.dist-info/RECORD,,
355
+ alita_sdk-0.3.370.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
356
+ alita_sdk-0.3.370.dist-info/METADATA,sha256=7o5P_ba4fUU5FVQU9htx-olWpTUnrpVOcfl2o3DwSEs,19071
357
+ alita_sdk-0.3.370.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
358
+ alita_sdk-0.3.370.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
359
+ alita_sdk-0.3.370.dist-info/RECORD,,