alita-sdk 0.3.215__py3-none-any.whl → 0.3.216__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.
@@ -80,6 +80,7 @@ _safe_import_tool('pptx', 'pptx', 'get_tools', 'PPTXToolkit')
80
80
  _safe_import_tool('postman', 'postman', 'get_tools', 'PostmanToolkit')
81
81
  _safe_import_tool('memory', 'memory', 'get_tools', 'MemoryToolkit')
82
82
  _safe_import_tool('zephyr_squad', 'zephyr_squad', 'get_tools', 'ZephyrSquadToolkit')
83
+ _safe_import_tool('zephyr_essential', 'zephyr_essential', 'get_tools', 'ZephyrEssentialToolkit')
83
84
  _safe_import_tool('slack', 'slack', 'get_tools', 'SlackToolkit')
84
85
  _safe_import_tool('bigquery', 'google.bigquery', 'get_tools', 'BigQueryToolkit')
85
86
  _safe_import_tool('delta_lake', 'aws.delta_lake', 'get_tools', 'DeltaLakeToolkit')
@@ -1,5 +1,6 @@
1
1
  import ast
2
2
  import fnmatch
3
+ import json
3
4
  import logging
4
5
  import traceback
5
6
  from typing import Any, Optional, List, Literal, Dict, Generator
@@ -375,6 +376,12 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
375
376
 
376
377
  self._init_vector_store(collection_suffix)._clean_collection()
377
378
 
379
+ def list_collections(self):
380
+ """
381
+ Lists all collections in the vector store
382
+ """
383
+ return ','.join([collection.name for collection in self.vectoradapter.vectorstore._client.list_collections()])
384
+
378
385
  def search_index(self,
379
386
  query: str,
380
387
  collection_suffix: str = "",
@@ -386,17 +393,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
386
393
  **kwargs):
387
394
  """ Searches indexed documents in the vector store."""
388
395
  vectorstore = self._init_vector_store(collection_suffix)
389
- return vectorstore.search_documents(
390
- query,
391
- doctype=self.doctype,
392
- filter=filter,
393
- cut_off=cut_off,
394
- search_top=search_top,
396
+ found_docs = vectorstore.search_documents(
397
+ query,
398
+ doctype=self.doctype,
399
+ filter=filter,
400
+ cut_off=cut_off,
401
+ search_top=search_top,
395
402
  reranker=reranker,
396
- full_text_search=full_text_search,
397
- reranking_config=reranking_config,
403
+ full_text_search=full_text_search,
404
+ reranking_config=reranking_config,
398
405
  extended_search=extended_search
399
406
  )
407
+ return f"Found {len(found_docs)} documents matching the query\n{json.dumps(found_docs, indent=4)}" if found_docs else "No documents found matching the query."
400
408
 
401
409
  def stepback_search_index(self,
402
410
  query: str,
@@ -410,17 +418,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
410
418
  **kwargs):
411
419
  """ Searches indexed documents in the vector store."""
412
420
  vectorstore = self._init_vector_store(collection_suffix)
413
- return vectorstore.stepback_search(
414
- query,
415
- messages,
416
- self.doctype,
417
- filter=filter,
418
- cut_off=cut_off,
421
+ found_docs = vectorstore.stepback_search(
422
+ query,
423
+ messages,
424
+ self.doctype,
425
+ filter=filter,
426
+ cut_off=cut_off,
419
427
  search_top=search_top,
420
- full_text_search=full_text_search,
421
- reranking_config=reranking_config,
428
+ full_text_search=full_text_search,
429
+ reranking_config=reranking_config,
422
430
  extended_search=extended_search
423
431
  )
432
+ return f"Found {len(found_docs)} documents matching the query\n{json.dumps(found_docs, indent=4)}" if found_docs else "No documents found matching the query."
424
433
 
425
434
  def stepback_summary_index(self,
426
435
  query: str,
@@ -483,6 +492,14 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
483
492
  "description": self.remove_index.__doc__,
484
493
  "args_schema": RemoveIndexParams
485
494
  },
495
+ {
496
+ "name": "list_collections",
497
+ "mode": "list_collections",
498
+ "ref": self.list_collections,
499
+ "description": self.list_collections.__doc__,
500
+ "args_schema": create_model("ListCollectionsParams") # No parameters
501
+ },
502
+
486
503
  ]
487
504
 
488
505
 
@@ -0,0 +1,58 @@
1
+ from typing import List, Literal, Optional
2
+
3
+ from langchain_core.tools import BaseToolkit, BaseTool
4
+ from pydantic import create_model, BaseModel, Field, SecretStr
5
+
6
+ from .api_wrapper import ZephyrEssentialApiWrapper
7
+ from ..base.tool import BaseAction
8
+ from ..utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length
9
+
10
+ name = "zephyr_essential"
11
+
12
+ def get_tools(tool):
13
+ return ZephyrEssentialToolkit().get_toolkit(
14
+ selected_tools=tool['settings'].get('selected_tools', []),
15
+ token=tool['settings']["token"],
16
+ toolkit_name=tool.get('toolkit_name')
17
+ ).get_tools()
18
+
19
+ class ZephyrEssentialToolkit(BaseToolkit):
20
+ tools: List[BaseTool] = []
21
+ toolkit_max_length: int = 0
22
+
23
+ @staticmethod
24
+ def toolkit_config_schema() -> BaseModel:
25
+ selected_tools = {x['name']: x['args_schema'].schema() for x in ZephyrEssentialApiWrapper.model_construct().get_available_tools()}
26
+ ZephyrEssentialToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
27
+ return create_model(
28
+ name,
29
+ token=(str, Field(description="Bearer api token")),
30
+ base_url=(Optional[str], Field(description="Zephyr Essential base url", default=None)),
31
+ selected_tools=(List[Literal[tuple(selected_tools)]], Field(default=[], json_schema_extra={'args_schemas': selected_tools})),
32
+ __config__={'json_schema_extra': {'metadata': {"label": "Zephyr Essential", "icon_url": "zephyr.svg",
33
+ "categories": ["test management"],
34
+ "extra_categories": ["test automation", "test case management", "test planning"]
35
+ }}}
36
+ )
37
+
38
+ @classmethod
39
+ def get_toolkit(cls, selected_tools: list[str] | None = None, toolkit_name: Optional[str] = None, **kwargs):
40
+ zephyr_api_wrapper = ZephyrEssentialApiWrapper(**kwargs)
41
+ prefix = clean_string(toolkit_name, cls.toolkit_max_length) + TOOLKIT_SPLITTER if toolkit_name else ''
42
+ available_tools = zephyr_api_wrapper.get_available_tools()
43
+ tools = []
44
+ for tool in available_tools:
45
+ if selected_tools:
46
+ if tool["name"] not in selected_tools:
47
+ continue
48
+ tools.append(BaseAction(
49
+ api_wrapper=zephyr_api_wrapper,
50
+ name=prefix + tool["name"],
51
+ description=tool["description"],
52
+ args_schema=tool["args_schema"]
53
+ ))
54
+ return cls(tools=tools)
55
+
56
+ def get_tools(self):
57
+ return self.tools
58
+