alita-sdk 0.3.215__py3-none-any.whl → 0.3.217__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.
- alita_sdk/tools/__init__.py +1 -0
- alita_sdk/tools/elitea_base.py +35 -16
- alita_sdk/tools/zephyr_enterprise/__init__.py +13 -1
- alita_sdk/tools/zephyr_essential/__init__.py +70 -0
- alita_sdk/tools/zephyr_essential/api_wrapper.py +904 -0
- alita_sdk/tools/zephyr_essential/client.py +219 -0
- alita_sdk/tools/zephyr_scale/api_wrapper.py +31 -68
- {alita_sdk-0.3.215.dist-info → alita_sdk-0.3.217.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.215.dist-info → alita_sdk-0.3.217.dist-info}/RECORD +12 -9
- {alita_sdk-0.3.215.dist-info → alita_sdk-0.3.217.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.215.dist-info → alita_sdk-0.3.217.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.215.dist-info → alita_sdk-0.3.217.dist-info}/top_level.txt +0 -0
alita_sdk/tools/__init__.py
CHANGED
@@ -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')
|
alita_sdk/tools/elitea_base.py
CHANGED
@@ -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
|
@@ -326,6 +327,7 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
326
327
|
yield processed_doc
|
327
328
|
|
328
329
|
|
330
|
+
# TODO: init store once and re-use the instance
|
329
331
|
def _init_vector_store(self, collection_suffix: str = "", embeddings: Optional[Any] = None):
|
330
332
|
""" Initializes the vector store wrapper with the provided parameters."""
|
331
333
|
try:
|
@@ -375,6 +377,13 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
375
377
|
|
376
378
|
self._init_vector_store(collection_suffix)._clean_collection()
|
377
379
|
|
380
|
+
def list_collections(self):
|
381
|
+
"""
|
382
|
+
Lists all collections in the vector store
|
383
|
+
"""
|
384
|
+
vector_client = self._init_vector_store().vectoradapter.vectorstore._client
|
385
|
+
return ','.join([collection.name for collection in vector_client.list_collections()])
|
386
|
+
|
378
387
|
def search_index(self,
|
379
388
|
query: str,
|
380
389
|
collection_suffix: str = "",
|
@@ -386,17 +395,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
386
395
|
**kwargs):
|
387
396
|
""" Searches indexed documents in the vector store."""
|
388
397
|
vectorstore = self._init_vector_store(collection_suffix)
|
389
|
-
|
390
|
-
query,
|
391
|
-
doctype=self.doctype,
|
392
|
-
filter=filter,
|
393
|
-
cut_off=cut_off,
|
394
|
-
search_top=search_top,
|
398
|
+
found_docs = vectorstore.search_documents(
|
399
|
+
query,
|
400
|
+
doctype=self.doctype,
|
401
|
+
filter=filter,
|
402
|
+
cut_off=cut_off,
|
403
|
+
search_top=search_top,
|
395
404
|
reranker=reranker,
|
396
|
-
full_text_search=full_text_search,
|
397
|
-
reranking_config=reranking_config,
|
405
|
+
full_text_search=full_text_search,
|
406
|
+
reranking_config=reranking_config,
|
398
407
|
extended_search=extended_search
|
399
408
|
)
|
409
|
+
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
410
|
|
401
411
|
def stepback_search_index(self,
|
402
412
|
query: str,
|
@@ -410,17 +420,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
410
420
|
**kwargs):
|
411
421
|
""" Searches indexed documents in the vector store."""
|
412
422
|
vectorstore = self._init_vector_store(collection_suffix)
|
413
|
-
|
414
|
-
query,
|
415
|
-
messages,
|
416
|
-
self.doctype,
|
417
|
-
filter=filter,
|
418
|
-
cut_off=cut_off,
|
423
|
+
found_docs = vectorstore.stepback_search(
|
424
|
+
query,
|
425
|
+
messages,
|
426
|
+
self.doctype,
|
427
|
+
filter=filter,
|
428
|
+
cut_off=cut_off,
|
419
429
|
search_top=search_top,
|
420
|
-
full_text_search=full_text_search,
|
421
|
-
reranking_config=reranking_config,
|
430
|
+
full_text_search=full_text_search,
|
431
|
+
reranking_config=reranking_config,
|
422
432
|
extended_search=extended_search
|
423
433
|
)
|
434
|
+
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
435
|
|
425
436
|
def stepback_summary_index(self,
|
426
437
|
query: str,
|
@@ -483,6 +494,14 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
483
494
|
"description": self.remove_index.__doc__,
|
484
495
|
"args_schema": RemoveIndexParams
|
485
496
|
},
|
497
|
+
{
|
498
|
+
"name": "list_collections",
|
499
|
+
"mode": "list_collections",
|
500
|
+
"ref": self.list_collections,
|
501
|
+
"description": self.list_collections.__doc__,
|
502
|
+
"args_schema": create_model("ListCollectionsParams") # No parameters
|
503
|
+
},
|
504
|
+
|
486
505
|
]
|
487
506
|
|
488
507
|
|
@@ -13,7 +13,15 @@ def get_tools(tool):
|
|
13
13
|
selected_tools=tool['settings'].get('selected_tools', []),
|
14
14
|
base_url=tool['settings']['base_url'],
|
15
15
|
token=tool['settings']['token'],
|
16
|
-
toolkit_name=tool.get('toolkit_name')
|
16
|
+
toolkit_name=tool.get('toolkit_name'),
|
17
|
+
llm=tool['settings'].get('llm', None),
|
18
|
+
|
19
|
+
# indexer settings
|
20
|
+
connection_string=tool['settings'].get('connection_string', None),
|
21
|
+
collection_name=f"{tool.get('toolkit_name')}_{str(tool['id'])}",
|
22
|
+
embedding_model="HuggingFaceEmbeddings",
|
23
|
+
embedding_model_params={"model_name": "sentence-transformers/all-MiniLM-L6-v2"},
|
24
|
+
vectorstore_type="PGVector"
|
17
25
|
).get_tools()
|
18
26
|
|
19
27
|
class ZephyrEnterpriseToolkit(BaseToolkit):
|
@@ -29,6 +37,10 @@ class ZephyrEnterpriseToolkit(BaseToolkit):
|
|
29
37
|
name,
|
30
38
|
base_url=(str, Field(description="Zephyr Enterprise base URL", json_schema_extra={'toolkit_name': True, 'max_toolkit_length': ZephyrEnterpriseToolkit.toolkit_max_length })),
|
31
39
|
token=(SecretStr, Field(description="API token", json_schema_extra={'secret': True})),
|
40
|
+
# indexer settings
|
41
|
+
connection_string=(Optional[SecretStr], Field(description="Connection string for vectorstore",
|
42
|
+
default=None,
|
43
|
+
json_schema_extra={'secret': True})),
|
32
44
|
selected_tools=(List[Literal[tuple(selected_tools)]], []),
|
33
45
|
__config__=ConfigDict(json_schema_extra={
|
34
46
|
'metadata': {
|
@@ -0,0 +1,70 @@
|
|
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
|
+
llm = tool['settings'].get('llm', None),
|
18
|
+
|
19
|
+
# indexer settings
|
20
|
+
connection_string = tool['settings'].get('connection_string', None),
|
21
|
+
collection_name = f"{tool.get('toolkit_name')}_{str(tool['id'])}",
|
22
|
+
embedding_model = "HuggingFaceEmbeddings",
|
23
|
+
embedding_model_params = {"model_name": "sentence-transformers/all-MiniLM-L6-v2"},
|
24
|
+
vectorstore_type = "PGVector"
|
25
|
+
).get_tools()
|
26
|
+
|
27
|
+
class ZephyrEssentialToolkit(BaseToolkit):
|
28
|
+
tools: List[BaseTool] = []
|
29
|
+
toolkit_max_length: int = 0
|
30
|
+
|
31
|
+
@staticmethod
|
32
|
+
def toolkit_config_schema() -> BaseModel:
|
33
|
+
selected_tools = {x['name']: x['args_schema'].schema() for x in ZephyrEssentialApiWrapper.model_construct().get_available_tools()}
|
34
|
+
ZephyrEssentialToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
|
35
|
+
return create_model(
|
36
|
+
name,
|
37
|
+
token=(str, Field(description="Bearer api token")),
|
38
|
+
base_url=(Optional[str], Field(description="Zephyr Essential base url", default=None)),
|
39
|
+
selected_tools=(List[Literal[tuple(selected_tools)]], Field(default=[], json_schema_extra={'args_schemas': selected_tools})),
|
40
|
+
# indexer settings
|
41
|
+
connection_string=(Optional[SecretStr], Field(description="Connection string for vectorstore",
|
42
|
+
default=None,
|
43
|
+
json_schema_extra={'secret': True})),
|
44
|
+
__config__={'json_schema_extra': {'metadata': {"label": "Zephyr Essential", "icon_url": "zephyr.svg",
|
45
|
+
"categories": ["test management"],
|
46
|
+
"extra_categories": ["test automation", "test case management", "test planning"]
|
47
|
+
}}}
|
48
|
+
)
|
49
|
+
|
50
|
+
@classmethod
|
51
|
+
def get_toolkit(cls, selected_tools: list[str] | None = None, toolkit_name: Optional[str] = None, **kwargs):
|
52
|
+
zephyr_api_wrapper = ZephyrEssentialApiWrapper(**kwargs)
|
53
|
+
prefix = clean_string(toolkit_name, cls.toolkit_max_length) + TOOLKIT_SPLITTER if toolkit_name else ''
|
54
|
+
available_tools = zephyr_api_wrapper.get_available_tools()
|
55
|
+
tools = []
|
56
|
+
for tool in available_tools:
|
57
|
+
if selected_tools:
|
58
|
+
if tool["name"] not in selected_tools:
|
59
|
+
continue
|
60
|
+
tools.append(BaseAction(
|
61
|
+
api_wrapper=zephyr_api_wrapper,
|
62
|
+
name=prefix + tool["name"],
|
63
|
+
description=tool["description"],
|
64
|
+
args_schema=tool["args_schema"]
|
65
|
+
))
|
66
|
+
return cls(tools=tools)
|
67
|
+
|
68
|
+
def get_tools(self):
|
69
|
+
return self.tools
|
70
|
+
|