alita-sdk 0.3.208__py3-none-any.whl → 0.3.209__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.
@@ -9,7 +9,7 @@ from langchain_core.callbacks import dispatch_custom_event
9
9
  from langchain_core.messages import HumanMessage, AIMessage, SystemMessage, BaseMessage
10
10
  from langchain_core.runnables import Runnable
11
11
  from langchain_core.runnables import RunnableConfig
12
- from langchain_core.tools import BaseTool
12
+ from langchain_core.tools import BaseTool, ToolException
13
13
  from langgraph.channels.ephemeral_value import EphemeralValue
14
14
  from langgraph.graph import StateGraph
15
15
  from langgraph.graph.graph import END, START
@@ -506,10 +506,10 @@ def create_graph(
506
506
  for toolkit, selected_tools in connected_tools.items():
507
507
  for tool in selected_tools:
508
508
  tool_names.append(f"{toolkit}___{tool}")
509
+ elif isinstance(connected_tools, list):
510
+ # for cases when tools are provided as a list of names with already bound toolkit_name
511
+ tool_names = connected_tools
509
512
 
510
- # Filter tools if specific tool names are provided
511
- available_tools = []
512
-
513
513
  if tool_names:
514
514
  # Filter tools by name
515
515
  tool_dict = {tool.name: tool for tool in tools if isinstance(tool, BaseTool)}
@@ -580,7 +580,10 @@ def create_graph(
580
580
  default_output=node['condition'].get('default_output', 'END')))
581
581
 
582
582
  # set default value for state variable at START
583
- entry_point = clean_string(schema['entry_point'])
583
+ try:
584
+ entry_point = clean_string(schema['entry_point'])
585
+ except KeyError:
586
+ raise ToolException("Entry point is not defined in the schema. Please define 'entry_point' in the schema.")
584
587
  for key, value in state.items():
585
588
  if 'type' in value and 'value' in value:
586
589
  # set default value for state variable if it is defined in the schema
@@ -199,13 +199,12 @@ class VectorStoreWrapper(BaseToolApiWrapper):
199
199
  data = store.get(include=['documents', 'metadatas'])
200
200
  # re-structure data to be more usable
201
201
  for doc_str, meta, db_id in zip(data['documents'], data['metadatas'], data['ids']):
202
- doc = json.loads(doc_str)
203
202
  doc_id = str(meta['id'])
204
203
  dependent_docs = meta.get(IndexerKeywords.DEPENDENT_DOCS.value, [])
205
204
  parent_id = meta.get(IndexerKeywords.PARENT.value, -1)
206
205
  result[doc_id] = {
207
206
  'metadata': meta,
208
- 'document': doc,
207
+ 'document': doc_str,
209
208
  'id': db_id,
210
209
  IndexerKeywords.DEPENDENT_DOCS.value: dependent_docs,
211
210
  IndexerKeywords.PARENT.value: parent_id
@@ -11,6 +11,7 @@ from ..elitea_base import BaseVectorStoreToolApiWrapper, BaseIndexParams
11
11
  from langchain_core.documents import Document
12
12
 
13
13
  from ...runtime.utils.utils import IndexerKeywords
14
+ from ..utils.content_parser import parse_file_content
14
15
 
15
16
  try:
16
17
  from alita_sdk.runtime.langchain.interfaces.llm_processor import get_embeddings
@@ -658,8 +659,12 @@ class TestrailAPIWrapper(BaseVectorStoreToolApiWrapper):
658
659
  page_content = "This filetype is not supported."
659
660
  if attachment['filetype'] == 'txt' :
660
661
  page_content = self._client.get(endpoint=f"get_attachment/{attachment['id']}")
661
- # TODO: add support for other file types
662
- # use utility to handle different types (tools/utils)
662
+ else:
663
+ try:
664
+ attachment_path = self._client.attachments.get_attachment(attachment_id=attachment['id'], path=f"./{attachment['filename']}")
665
+ page_content = parse_file_content(file_name=attachment['filename'], file_content=attachment_path.read_bytes(), llm=self.llm, is_capture_image=True)
666
+ except Exception as e:
667
+ logger.error(f"Unable to parse page's content with type: {attachment['filetype']}: {e}")
663
668
  return page_content
664
669
 
665
670
  def _to_markup(self, data: List[Dict], output_format: str) -> str:
@@ -11,9 +11,12 @@ import pymupdf
11
11
  from langchain_core.tools import ToolException
12
12
  from transformers import BlipProcessor, BlipForConditionalGeneration
13
13
  from langchain_core.messages import HumanMessage
14
+ from logging import getLogger
14
15
 
15
16
  from ...runtime.langchain.tools.utils import bytes_to_base64
16
17
 
18
+ logger = getLogger(__name__)
19
+
17
20
  image_processing_prompt='''
18
21
  You are an AI model designed for analyzing images. Your task is to accurately describe the content of the given image. Depending on the type of image, follow these specific instructions:
19
22
 
@@ -56,7 +59,33 @@ Be as precise and thorough as possible in your responses. If something is unclea
56
59
 
57
60
  IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp', 'svg']
58
61
 
59
- def parse_file_content(file_name, file_content, is_capture_image: bool = False, page_number: int = None, sheet_name: str = None, llm=None):
62
+
63
+ def parse_file_content(file_name=None, file_content=None, is_capture_image: bool = False, page_number: int = None,
64
+ sheet_name: str = None, llm=None, file_path: str = None):
65
+ """Parse the content of a file based on its type and return the parsed content.
66
+
67
+ Args:
68
+ file_name (str): The name of the file to parse.
69
+ file_content (bytes): The content of the file as bytes.
70
+ is_capture_image (bool): Whether to capture images from the file.
71
+ page_number (int, optional): The specific page number to parse for PDF or PPTX files.
72
+ sheet_name (str, optional): The specific sheet name to parse for Excel files.
73
+ llm: The language model to use for image processing.
74
+ file_path (str, optional): The path to the file if it needs to be read from disk.
75
+ Returns:
76
+ str: The parsed content of the file.
77
+ Raises:
78
+ ToolException: If the file type is not supported or if there is an error reading the file.
79
+ """
80
+
81
+ if (file_path and (file_name or file_content)) or (not file_path and (not file_name or file_content is None)):
82
+ raise ToolException("Either (file_name and file_content) or file_path must be provided, but not both.")
83
+
84
+ if file_path:
85
+ file_content = file_to_bytes(file_path)
86
+ if file_content is None:
87
+ return ToolException(f"File not found or could not be read: {file_path}")
88
+ file_name = file_path.split('/')[-1] # Extract file name from path
60
89
  if file_name.endswith('.txt'):
61
90
  return parse_txt(file_content)
62
91
  elif file_name.endswith('.docx'):
@@ -176,4 +205,25 @@ def __perform_llm_prediction_for_image(llm, image: bytes, image_format='png', pr
176
205
  },
177
206
  ])
178
207
  ])
179
- return f"\n[Image description: {result.content}]\n"
208
+ return f"\n[Image description: {result.content}]\n"
209
+
210
+ def file_to_bytes(filepath):
211
+ """
212
+ Reads a file and returns its content as a bytes object.
213
+
214
+ Args:
215
+ filepath (str): The path to the file.
216
+
217
+ Returns:
218
+ bytes: The content of the file as a bytes object.
219
+ """
220
+ try:
221
+ with open(filepath, "rb") as f:
222
+ file_content_bytes = f.read()
223
+ return file_content_bytes
224
+ except FileNotFoundError:
225
+ logger.error(f"File not found: {filepath}")
226
+ return None
227
+ except Exception as e:
228
+ logger.error(f"Error reading file {filepath}: {e}")
229
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.208
3
+ Version: 0.3.209
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 <lifedjik@gmail.com>, Artem Dubrovskiy <ad13box@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -12,7 +12,7 @@ alita_sdk/runtime/langchain/assistant.py,sha256=Bn9vUyZlFAP-D9Bh3zc2G1ZQkh5rr2c2
12
12
  alita_sdk/runtime/langchain/chat_message_template.py,sha256=kPz8W2BG6IMyITFDA5oeb5BxVRkHEVZhuiGl4MBZKdc,2176
13
13
  alita_sdk/runtime/langchain/constants.py,sha256=eHVJ_beJNTf1WJo4yq7KMK64fxsRvs3lKc34QCXSbpk,3319
14
14
  alita_sdk/runtime/langchain/indexer.py,sha256=0ENHy5EOhThnAiYFc7QAsaTNp9rr8hDV_hTK8ahbatk,37592
15
- alita_sdk/runtime/langchain/langraph_agent.py,sha256=QwD9NZ74Hp4rZvP7nirzOmjFJhfJ7eiuAvsq7aAW4Uw,43563
15
+ alita_sdk/runtime/langchain/langraph_agent.py,sha256=csK5vNXULMImBsfNzb6B2HgXuCWgCNYf3DIVvnmk5uQ,43835
16
16
  alita_sdk/runtime/langchain/mixedAgentParser.py,sha256=M256lvtsL3YtYflBCEp-rWKrKtcY1dJIyRGVv7KW9ME,2611
17
17
  alita_sdk/runtime/langchain/mixedAgentRenderes.py,sha256=asBtKqm88QhZRILditjYICwFVKF5KfO38hu2O-WrSWE,5964
18
18
  alita_sdk/runtime/langchain/store_manager.py,sha256=i8Fl11IXJhrBXq1F1ukEVln57B1IBe-tqSUvfUmBV4A,2218
@@ -79,7 +79,7 @@ alita_sdk/runtime/tools/pgvector_search.py,sha256=NN2BGAnq4SsDHIhUcFZ8d_dbEOM8Qw
79
79
  alita_sdk/runtime/tools/prompt.py,sha256=nJafb_e5aOM1Rr3qGFCR-SKziU9uCsiP2okIMs9PppM,741
80
80
  alita_sdk/runtime/tools/router.py,sha256=wCvZjVkdXK9dMMeEerrgKf5M790RudH68pDortnHSz0,1517
81
81
  alita_sdk/runtime/tools/tool.py,sha256=lE1hGi6qOAXG7qxtqxarD_XMQqTghdywf261DZawwno,5631
82
- alita_sdk/runtime/tools/vectorstore.py,sha256=RhGg2gGY5PFfllouuwB5uLkM_lAlr_SqpsziLKgXq1U,30672
82
+ alita_sdk/runtime/tools/vectorstore.py,sha256=o818tabxkG-o1Opv7zQy9lIL4sW2lfEHNCJrNiU7uPU,30634
83
83
  alita_sdk/runtime/utils/AlitaCallback.py,sha256=E4LlSBuCHWiUq6W7IZExERHZY0qcmdjzc_rJlF2iQIw,7356
84
84
  alita_sdk/runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
85
85
  alita_sdk/runtime/utils/constants.py,sha256=Xntx1b_uxUzT4clwqHA_U6K8y5bBqf_4lSQwXdcWrp4,13586
@@ -280,9 +280,9 @@ alita_sdk/tools/sql/models.py,sha256=AKJgSl_kEEz4fZfw3kbvdGHXaRZ-yiaqfJOB6YOj3i0
280
280
  alita_sdk/tools/testio/__init__.py,sha256=qi12wyJXN02hrUXg08CbijcCL5pi30JMbJfiXjn1Zr0,2646
281
281
  alita_sdk/tools/testio/api_wrapper.py,sha256=BvmL5h634BzG6p7ajnQLmj-uoAw1gjWnd4FHHu1h--Q,21638
282
282
  alita_sdk/tools/testrail/__init__.py,sha256=YILz5ZjkHfBg1tQ-FKFBP_s0uo2WDY110Qgsg0kBntM,4157
283
- alita_sdk/tools/testrail/api_wrapper.py,sha256=Sfe_5sJk-cIAYRlpO7DcCN117UAPbBIzf_HI6fVrOQ8,31999
283
+ alita_sdk/tools/testrail/api_wrapper.py,sha256=5T5Mowo2xW-s2k4mB9IL7kSHok8I7C2UMcz1Uq25_NY,32419
284
284
  alita_sdk/tools/utils/__init__.py,sha256=155xepXPr4OEzs2Mz5YnjXcBpxSv1X2eznRUVoPtyK0,3268
285
- alita_sdk/tools/utils/content_parser.py,sha256=Ou967dO3JnnL9kAidzofwV6TVe2_ul86ZMjcBOK-VnA,7811
285
+ alita_sdk/tools/utils/content_parser.py,sha256=JiL3zXCadDR0DVt6Zgq03LxWXwxuYv8us84bYMeqYa4,9788
286
286
  alita_sdk/tools/xray/__init__.py,sha256=dn-Ine9mHF8c_yZ-pWkn-gvSvSmGwdrqxPJOz6Cmqc4,3297
287
287
  alita_sdk/tools/xray/api_wrapper.py,sha256=l7Cwvh_5bEaH0IM3yLo1PSClqV1E20wH_sEHaJntM3s,8517
288
288
  alita_sdk/tools/yagmail/__init__.py,sha256=c4Qn3em0tLxzRmFKpzbBgY9W2EnOoKf0azoDJHng5CY,2208
@@ -299,8 +299,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=VDsSFUTnBne1mFNssX2eLFxThXAhX
299
299
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=0AI_j27xVO5Gk5HQMFrqPTd4uvuVTpiZUicBrdfEpKg,2796
300
300
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=kmw_xol8YIYFplBLWTqP_VKPRhL_1ItDD0_vXTe_UuI,14906
301
301
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=R371waHsms4sllHCbijKYs90C-9Yu0sSR3N4SUfQOgU,5066
302
- alita_sdk-0.3.208.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
303
- alita_sdk-0.3.208.dist-info/METADATA,sha256=uohMy95DqgX2lMhZhmDs2u0PahKqvVC1p93Wu71kwhA,18917
304
- alita_sdk-0.3.208.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
305
- alita_sdk-0.3.208.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
306
- alita_sdk-0.3.208.dist-info/RECORD,,
302
+ alita_sdk-0.3.209.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
303
+ alita_sdk-0.3.209.dist-info/METADATA,sha256=mnXZpgZ6MJkT3kLO1byDa9SR9lTbzhkEaTZb803EPoo,18917
304
+ alita_sdk-0.3.209.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
305
+ alita_sdk-0.3.209.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
306
+ alita_sdk-0.3.209.dist-info/RECORD,,