alita-sdk 0.3.214__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.
- alita_sdk/tools/__init__.py +1 -0
- alita_sdk/tools/elitea_base.py +34 -19
- alita_sdk/tools/zephyr_essential/__init__.py +58 -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.214.dist-info → alita_sdk-0.3.216.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.214.dist-info → alita_sdk-0.3.216.dist-info}/RECORD +11 -8
- {alita_sdk-0.3.214.dist-info → alita_sdk-0.3.216.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.214.dist-info → alita_sdk-0.3.216.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.214.dist-info → alita_sdk-0.3.216.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
|
@@ -350,9 +351,7 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
350
351
|
"alita_sdk_options": {
|
351
352
|
"target_schema": collection_name,
|
352
353
|
},
|
353
|
-
|
354
|
-
# 'postgresql+psycopg://project_23_user:Rxu4QtM2InLVNnm62GX7@pgvector:5432/project_23'
|
355
|
-
"connection_string": 'postgresql+psycopg://postgres:yourpassword@localhost:5432/postgres'
|
354
|
+
"connection_string": self.connection_string.get_secret_value()
|
356
355
|
}
|
357
356
|
elif self.vectorstore_type == 'Chroma':
|
358
357
|
vectorstore_params = {
|
@@ -377,6 +376,12 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
377
376
|
|
378
377
|
self._init_vector_store(collection_suffix)._clean_collection()
|
379
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
|
+
|
380
385
|
def search_index(self,
|
381
386
|
query: str,
|
382
387
|
collection_suffix: str = "",
|
@@ -388,17 +393,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
388
393
|
**kwargs):
|
389
394
|
""" Searches indexed documents in the vector store."""
|
390
395
|
vectorstore = self._init_vector_store(collection_suffix)
|
391
|
-
|
392
|
-
query,
|
393
|
-
doctype=self.doctype,
|
394
|
-
filter=filter,
|
395
|
-
cut_off=cut_off,
|
396
|
-
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,
|
397
402
|
reranker=reranker,
|
398
|
-
full_text_search=full_text_search,
|
399
|
-
reranking_config=reranking_config,
|
403
|
+
full_text_search=full_text_search,
|
404
|
+
reranking_config=reranking_config,
|
400
405
|
extended_search=extended_search
|
401
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."
|
402
408
|
|
403
409
|
def stepback_search_index(self,
|
404
410
|
query: str,
|
@@ -412,17 +418,18 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
412
418
|
**kwargs):
|
413
419
|
""" Searches indexed documents in the vector store."""
|
414
420
|
vectorstore = self._init_vector_store(collection_suffix)
|
415
|
-
|
416
|
-
query,
|
417
|
-
messages,
|
418
|
-
self.doctype,
|
419
|
-
filter=filter,
|
420
|
-
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,
|
421
427
|
search_top=search_top,
|
422
|
-
full_text_search=full_text_search,
|
423
|
-
reranking_config=reranking_config,
|
428
|
+
full_text_search=full_text_search,
|
429
|
+
reranking_config=reranking_config,
|
424
430
|
extended_search=extended_search
|
425
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."
|
426
433
|
|
427
434
|
def stepback_summary_index(self,
|
428
435
|
query: str,
|
@@ -485,6 +492,14 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
485
492
|
"description": self.remove_index.__doc__,
|
486
493
|
"args_schema": RemoveIndexParams
|
487
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
|
+
|
488
503
|
]
|
489
504
|
|
490
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
|
+
|