alita-sdk 0.3.227__py3-none-any.whl → 0.3.229__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/configurations/__init__.py +66 -0
- alita_sdk/configurations/ado.py +41 -0
- alita_sdk/configurations/azure_search.py +21 -0
- alita_sdk/configurations/bigquery.py +23 -0
- alita_sdk/configurations/bitbucket.py +31 -0
- alita_sdk/configurations/confluence.py +36 -0
- alita_sdk/configurations/delta_lake.py +24 -0
- alita_sdk/configurations/github.py +45 -0
- alita_sdk/configurations/gitlab.py +31 -0
- alita_sdk/configurations/jira.py +36 -0
- alita_sdk/configurations/pgvector.py +18 -0
- alita_sdk/configurations/postman.py +30 -0
- alita_sdk/configurations/qtest.py +20 -0
- alita_sdk/configurations/service_now.py +31 -0
- alita_sdk/configurations/slack.py +35 -0
- alita_sdk/configurations/testrail.py +20 -0
- alita_sdk/runtime/toolkits/configurations.py +4 -0
- alita_sdk/runtime/toolkits/tools.py +1 -1
- alita_sdk/tools/ado/__init__.py +7 -7
- alita_sdk/tools/ado/repos/__init__.py +22 -31
- alita_sdk/tools/ado/wiki/ado_wrapper.py +13 -7
- alita_sdk/tools/aws/delta_lake/__init__.py +9 -13
- alita_sdk/tools/azure_ai/search/__init__.py +9 -15
- alita_sdk/tools/bitbucket/__init__.py +8 -11
- alita_sdk/tools/confluence/__init__.py +20 -20
- alita_sdk/tools/confluence/api_wrapper.py +11 -4
- alita_sdk/tools/elitea_base.py +1 -1
- alita_sdk/tools/github/__init__.py +22 -45
- alita_sdk/tools/gitlab/__init__.py +8 -8
- alita_sdk/tools/google/bigquery/__init__.py +5 -26
- alita_sdk/tools/jira/__init__.py +18 -18
- alita_sdk/tools/postman/__init__.py +5 -5
- alita_sdk/tools/qtest/__init__.py +3 -2
- alita_sdk/tools/servicenow/__init__.py +7 -5
- alita_sdk/tools/slack/__init__.py +6 -7
- alita_sdk/tools/testrail/__init__.py +8 -11
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +6 -5
- {alita_sdk-0.3.227.dist-info → alita_sdk-0.3.229.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.227.dist-info → alita_sdk-0.3.229.dist-info}/RECORD +42 -25
- {alita_sdk-0.3.227.dist-info → alita_sdk-0.3.229.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.227.dist-info → alita_sdk-0.3.229.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.227.dist-info → alita_sdk-0.3.229.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,12 @@
|
|
1
1
|
from typing import List, Literal, Optional
|
2
2
|
|
3
3
|
from langchain_core.tools import BaseTool, BaseToolkit
|
4
|
-
from pydantic import BaseModel, Field, create_model
|
4
|
+
from pydantic import BaseModel, Field, create_model
|
5
5
|
|
6
6
|
import requests
|
7
|
+
|
8
|
+
from ....configurations.ado import AdoReposConfiguration
|
9
|
+
from ....configurations.pgvector import PgVectorConfiguration
|
7
10
|
from ...base.tool import BaseAction
|
8
11
|
from .repos_wrapper import ReposApiWrapper
|
9
12
|
from ...utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length, check_connection_response
|
@@ -14,16 +17,16 @@ name = "ado_repos"
|
|
14
17
|
def _get_toolkit(tool) -> BaseToolkit:
|
15
18
|
return AzureDevOpsReposToolkit().get_toolkit(
|
16
19
|
selected_tools=tool['settings'].get('selected_tools', []),
|
17
|
-
organization_url=tool['settings'].get('organization_url', ""),
|
18
|
-
project=tool['settings'].get('project', ""),
|
19
|
-
token=tool['settings'].get('token', ""),
|
20
|
+
organization_url=tool['settings'].get('ado_repos_configuration').get('ado_configuration').get('organization_url', ""),
|
21
|
+
project=tool['settings'].get('ado_repos_configuration').get('ado_configuration').get('project', ""),
|
22
|
+
token=tool['settings'].get('ado_repos_configuration').get('ado_configuration').get('token', ""),
|
20
23
|
limit=tool['settings'].get('limit', 5),
|
21
|
-
repository_id=tool['settings'].get('repository_id', ""),
|
24
|
+
repository_id=tool['settings'].get('ado_repos_configuration').get('repository_id', ""),
|
22
25
|
base_branch=tool['settings'].get('base_branch', ""),
|
23
26
|
active_branch=tool['settings'].get('active_branch', ""),
|
24
27
|
toolkit_name=tool['settings'].get('toolkit_name', ""),
|
25
28
|
connection_string=tool['settings'].get('connection_string', None),
|
26
|
-
collection_name=
|
29
|
+
collection_name=tool['toolkit_name'],
|
27
30
|
doctype='code',
|
28
31
|
embedding_model="HuggingFaceEmbeddings",
|
29
32
|
embedding_model_params={"model_name": "sentence-transformers/all-MiniLM-L6-v2"},
|
@@ -46,33 +49,21 @@ class AzureDevOpsReposToolkit(BaseToolkit):
|
|
46
49
|
AzureDevOpsReposToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
|
47
50
|
m = create_model(
|
48
51
|
name,
|
49
|
-
|
50
|
-
|
51
|
-
json_schema_extra={
|
52
|
-
'configuration': True,
|
53
|
-
"configuration_title": True
|
54
|
-
})),
|
55
|
-
project=(str, Field(title="Project", description="ADO project", json_schema_extra={'configuration': True})),
|
56
|
-
repository_id=(str, Field(title="Repository ID", description="ADO repository ID",
|
57
|
-
json_schema_extra={
|
58
|
-
'max_toolkit_length': AzureDevOpsReposToolkit.toolkit_max_length,
|
59
|
-
'configuration': True})),
|
60
|
-
token=(SecretStr, Field(title="Token", description="ADO token", json_schema_extra={'secret': True, 'configuration': True})),
|
52
|
+
ado_repos_configuration=(Optional[AdoReposConfiguration], Field(description="Ado Repos configuration", default=None,
|
53
|
+
json_schema_extra={'configuration_types': ['ado_repos']})),
|
61
54
|
base_branch=(Optional[str], Field(default="", title="Base branch", description="ADO base branch (e.g., main)")),
|
62
55
|
active_branch=(Optional[str], Field(default="", title="Active branch", description="ADO active branch (e.g., main)")),
|
63
56
|
|
64
57
|
# indexer settings
|
65
|
-
|
66
|
-
|
67
|
-
json_schema_extra={'secret': True})),
|
68
|
-
|
58
|
+
pgvector_configuration=(Optional[PgVectorConfiguration], Field(description="PgVector configuration", default=None, json_schema_extra={'configuration_types': ['pgvector']})),
|
59
|
+
json_schema_extra={'secret': True})),
|
69
60
|
# embedder settings
|
70
61
|
embedding_model=(str, Field(description="Embedding model: i.e. 'HuggingFaceEmbeddings', etc.",
|
71
|
-
|
62
|
+
default="HuggingFaceEmbeddings")),
|
72
63
|
embedding_model_params=(dict, Field(
|
73
|
-
|
74
|
-
|
75
|
-
|
64
|
+
description="Embedding model parameters: i.e. `{'model_name': 'sentence-transformers/all-MiniLM-L6-v2'}",
|
65
|
+
default={"model_name": "sentence-transformers/all-MiniLM-L6-v2"})),
|
66
|
+
|
76
67
|
selected_tools=(List[Literal[tuple(selected_tools)]], Field(default=[], json_schema_extra={'args_schemas': selected_tools})),
|
77
68
|
__config__={'json_schema_extra': {'metadata':
|
78
69
|
{
|
@@ -91,11 +82,11 @@ class AzureDevOpsReposToolkit(BaseToolkit):
|
|
91
82
|
},
|
92
83
|
"categories": ["code repositories"],
|
93
84
|
"extra_categories": ["code", "repository", "version control"],
|
94
|
-
"configuration_group": {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}
|
85
|
+
# "configuration_group": {
|
86
|
+
# "name": "ado_repos",
|
87
|
+
# "label": "Azure DevOps Repositories",
|
88
|
+
# "icon_url": "ado-repos-icon.svg",
|
89
|
+
# }
|
99
90
|
}}}
|
100
91
|
)
|
101
92
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import hashlib
|
1
2
|
import logging
|
2
3
|
from typing import Any, Dict, Generator, Optional
|
3
4
|
|
@@ -229,21 +230,26 @@ class AzureDevOpsApiWrapper(BaseVectorStoreToolApiWrapper):
|
|
229
230
|
logger.error(f"Unable to modify wiki page: {str(e)}")
|
230
231
|
return ToolException(f"Unable to modify wiki page: {str(e)}")
|
231
232
|
|
232
|
-
def _base_loader(self, wiki_identifier: str, **kwargs) -> Generator[Document, None, None]:
|
233
|
+
def _base_loader(self, wiki_identifier: str, title_contains: Optional[str] = None, **kwargs) -> Generator[Document, None, None]:
|
233
234
|
pages = self._client.get_pages_batch(pages_batch_request={}, project=self.project, wiki_identifier=wiki_identifier)
|
234
235
|
#
|
235
236
|
for page in pages:
|
236
237
|
content = self._client.get_page_by_id(project=self.project, wiki_identifier=wiki_identifier, id=page.id, include_content=True).page.content
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
238
|
+
content_hash = hashlib.sha256(content.encode("utf-8")).hexdigest()
|
239
|
+
title = page.path.rsplit("/", 1)[-1]
|
240
|
+
if not title_contains or (title_contains and title_contains.lower() in title.lower()):
|
241
|
+
yield Document(page_content=content, metadata={
|
242
|
+
'id': str(page.id),
|
243
|
+
'path': page.path,
|
244
|
+
'title': title,
|
245
|
+
'updated_on': content_hash
|
246
|
+
})
|
242
247
|
|
243
248
|
def _index_tool_params(self):
|
244
249
|
"""Return the parameters for indexing data."""
|
245
250
|
return {
|
246
|
-
"wiki_identifier": (str, Field(description="Wiki identifier to index, e.g., 'ABCProject.wiki'"))
|
251
|
+
"wiki_identifier": (str, Field(description="Wiki identifier to index, e.g., 'ABCProject.wiki'")),
|
252
|
+
'title_contains': (Optional[str], Field(default=None, description="Optional filter to include only pages with titles containing exact this string"))
|
247
253
|
}
|
248
254
|
|
249
255
|
@extend_with_vector_tools
|
@@ -5,6 +5,7 @@ from typing import List, Optional, Type
|
|
5
5
|
from langchain_core.tools import BaseTool, BaseToolkit
|
6
6
|
from pydantic import BaseModel, Field, SecretStr, computed_field, field_validator
|
7
7
|
|
8
|
+
from alita_sdk.configurations.delta_lake import DeltaLakeConfiguration
|
8
9
|
from ...utils import TOOLKIT_SPLITTER, clean_string, get_max_toolkit_length
|
9
10
|
from .api_wrapper import DeltaLakeApiWrapper
|
10
11
|
from .tool import DeltaLakeAction
|
@@ -53,12 +54,7 @@ class DeltaLakeToolkitConfig(BaseModel):
|
|
53
54
|
}
|
54
55
|
}
|
55
56
|
|
56
|
-
|
57
|
-
aws_secret_access_key: Optional[SecretStr] = Field(default=None, description="AWS secret access key", json_schema_extra={"secret": True, "configuration": True})
|
58
|
-
aws_session_token: Optional[SecretStr] = Field(default=None, description="AWS session token (optional)", json_schema_extra={"secret": True, "configuration": True})
|
59
|
-
aws_region: Optional[str] = Field(default=None, description="AWS region for Delta Lake storage", json_schema_extra={"configuration": True})
|
60
|
-
s3_path: Optional[str] = Field(default=None, description="S3 path to Delta Lake data (e.g., s3://bucket/path)", json_schema_extra={"configuration": True, "configuration_title": True})
|
61
|
-
table_path: Optional[str] = Field(default=None, description="Delta Lake table path (if not using s3_path)", json_schema_extra={"configuration": True})
|
57
|
+
delta_lake_configuration: Optional[DeltaLakeConfiguration] = Field(description="Delta Lake Configuration", json_schema_extra={"configuration_types": ["delta_lake"]})
|
62
58
|
selected_tools: List[str] = Field(default=[], description="Selected tools", json_schema_extra={"args_schemas": get_available_tools()})
|
63
59
|
|
64
60
|
@field_validator("selected_tools", mode="before", check_fields=False)
|
@@ -69,12 +65,12 @@ class DeltaLakeToolkitConfig(BaseModel):
|
|
69
65
|
def _get_toolkit(tool) -> BaseToolkit:
|
70
66
|
return DeltaLakeToolkit().get_toolkit(
|
71
67
|
selected_tools=tool["settings"].get("selected_tools", []),
|
72
|
-
aws_access_key_id=tool["settings"].get("aws_access_key_id", None),
|
73
|
-
aws_secret_access_key=tool["settings"].get("aws_secret_access_key", None),
|
74
|
-
aws_session_token=tool["settings"].get("aws_session_token", None),
|
75
|
-
aws_region=tool["settings"].get("aws_region", None),
|
76
|
-
s3_path=tool["settings"].get("s3_path", None),
|
77
|
-
table_path=tool["settings"].get("table_path", None),
|
68
|
+
aws_access_key_id=tool["settings"].get("delta_lake_configuration").get("aws_access_key_id", None),
|
69
|
+
aws_secret_access_key=tool["settings"].get("delta_lake_configuration").get("aws_secret_access_key", None),
|
70
|
+
aws_session_token=tool["settings"].get("delta_lake_configuration").get("aws_session_token", None),
|
71
|
+
aws_region=tool["settings"].get("delta_lake_configuration").get("aws_region", None),
|
72
|
+
s3_path=tool["settings"].get("delta_lake_configuration").get("s3_path", None),
|
73
|
+
table_path=tool["settings"].get("delta_lake_configuration").get("table_path", None),
|
78
74
|
toolkit_name=tool.get("toolkit_name"),
|
79
75
|
)
|
80
76
|
|
@@ -103,9 +99,9 @@ class DeltaLakeToolkit(BaseToolkit):
|
|
103
99
|
def available_tools(self) -> List[dict]:
|
104
100
|
return self.api_wrapper.get_available_tools()
|
105
101
|
|
106
|
-
@staticmethod
|
107
102
|
def toolkit_config_schema() -> Type[BaseModel]:
|
108
103
|
return DeltaLakeToolkitConfig
|
104
|
+
return m
|
109
105
|
|
110
106
|
@classmethod
|
111
107
|
def get_toolkit(
|
@@ -3,8 +3,9 @@ from typing import List, Optional, Literal
|
|
3
3
|
from .api_wrapper import AzureSearchApiWrapper
|
4
4
|
from ...base.tool import BaseAction
|
5
5
|
from langchain_core.tools import BaseToolkit, BaseTool
|
6
|
-
from pydantic import create_model, BaseModel, ConfigDict, Field
|
6
|
+
from pydantic import create_model, BaseModel, ConfigDict, Field
|
7
7
|
from ...utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length, check_connection_response
|
8
|
+
from ....configurations.azure_search import AzureSearchConfiguration
|
8
9
|
import requests
|
9
10
|
|
10
11
|
logger = getLogger(__name__)
|
@@ -14,10 +15,10 @@ name = "azure_search"
|
|
14
15
|
def get_tools(tool):
|
15
16
|
return AzureSearchToolkit().get_toolkit(
|
16
17
|
selected_tools=tool['settings'].get('selected_tools', []),
|
17
|
-
api_key=tool['settings'].get('api_key', None),
|
18
|
-
endpoint=tool['settings'].get('endpoint', None),
|
18
|
+
api_key=tool['settings'].get('azure_search_configuration', {}).get('api_key', None),
|
19
|
+
endpoint=tool['settings'].get('azure_search_configuration', {}).get('endpoint', None),
|
19
20
|
index_name=tool['settings'].get('index_name', None),
|
20
|
-
api_base=tool['settings'].get('api_base', None),
|
21
|
+
api_base=tool['settings'].get('azure_search_configuration', {}).get('api_base', None),
|
21
22
|
api_version=tool['settings'].get('api_version', None),
|
22
23
|
openai_api_key=tool['settings'].get('access_token', None),
|
23
24
|
model_name=tool['settings'].get('model_name', None),
|
@@ -38,18 +39,11 @@ class AzureSearchToolkit(BaseToolkit):
|
|
38
39
|
AzureSearchToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
|
39
40
|
m = create_model(
|
40
41
|
name,
|
41
|
-
api_key=(SecretStr, Field(description="API key", json_schema_extra={'secret': True, 'configuration': True})),
|
42
|
-
endpoint=(str, Field(title="Azure Search endpoint",
|
43
|
-
description="Azure Search endpoint",
|
44
|
-
json_schema_extra={
|
45
|
-
'configuration': True,
|
46
|
-
"configuration_title": True
|
47
|
-
})),
|
48
42
|
index_name=(str, Field(description="Azure Search index name")),
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
azure_search_configuration=(
|
44
|
+
Optional[AzureSearchConfiguration],
|
45
|
+
Field(description="Azure Search Configuration", json_schema_extra={'configuration_types': ['azure_search']})
|
46
|
+
),
|
53
47
|
api_version=(Optional[str], Field(description="API version", default=None)),
|
54
48
|
openai_api_key=(Optional[str], Field(description="Azure OpenAI API Key", default=None, json_schema_extra={'secret': True})),
|
55
49
|
model_name=(str, Field(description="Model name for Embeddings model", default=None)),
|
@@ -6,8 +6,10 @@ from .api_wrapper import BitbucketAPIWrapper
|
|
6
6
|
from .tools import __all__
|
7
7
|
from langchain_core.tools import BaseToolkit
|
8
8
|
from langchain_core.tools import BaseTool
|
9
|
-
from pydantic import BaseModel, Field, ConfigDict, create_model
|
9
|
+
from pydantic import BaseModel, Field, ConfigDict, create_model
|
10
10
|
from ..utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length, check_connection_response
|
11
|
+
from ...configurations.bitbucket import BitbucketConfiguration
|
12
|
+
from ...configurations.pgvector import PgVectorConfiguration
|
11
13
|
import requests
|
12
14
|
|
13
15
|
|
@@ -20,13 +22,13 @@ def get_tools(tool):
|
|
20
22
|
url=tool['settings']['url'],
|
21
23
|
project=tool['settings']['project'],
|
22
24
|
repository=tool['settings']['repository'],
|
23
|
-
username=tool['settings']
|
24
|
-
password=tool['settings']
|
25
|
+
username=tool['settings'].get('bitbucket_configuration', {}).get('username', ''),
|
26
|
+
password=tool['settings'].get('bitbucket_configuration', {}).get('password', ''),
|
25
27
|
branch=tool['settings']['branch'],
|
26
28
|
cloud=tool['settings'].get('cloud'),
|
27
29
|
llm=tool['settings'].get('llm', None),
|
28
30
|
alita=tool['settings'].get('alita', None),
|
29
|
-
connection_string=tool['settings'].get('connection_string', None),
|
31
|
+
connection_string=tool['settings'].get('pgvector_configuration', {}).get('connection_string', None),
|
30
32
|
collection_name=str(tool['toolkit_name']),
|
31
33
|
doctype='code',
|
32
34
|
embedding_model="HuggingFaceEmbeddings",
|
@@ -53,14 +55,9 @@ class AlitaBitbucketToolkit(BaseToolkit):
|
|
53
55
|
project=(str, Field(description="Project/Workspace", json_schema_extra={'configuration': True})),
|
54
56
|
repository=(str, Field(description="Repository", json_schema_extra={'max_toolkit_length': AlitaBitbucketToolkit.toolkit_max_length, 'configuration': True})),
|
55
57
|
branch=(str, Field(description="Main branch", default="main")),
|
56
|
-
username=(str, Field(description="Username", json_schema_extra={'configuration': True})),
|
57
|
-
password=(SecretStr, Field(description="GitLab private token", json_schema_extra={'secret': True, 'configuration': True})),
|
58
58
|
cloud=(Optional[bool], Field(description="Hosting Option", default=None)),
|
59
|
-
|
60
|
-
|
61
|
-
default=None,
|
62
|
-
json_schema_extra={'secret': True})),
|
63
|
-
|
59
|
+
bitbucket_configuration=(Optional[BitbucketConfiguration], Field(description="Bitbucket Configuration", json_schema_extra={'configuration_types': ['bitbucket']})),
|
60
|
+
pgvector_configuration=(Optional[PgVectorConfiguration], Field(description="PgVector Configuration", default={'configuration_types': ['pgvector']})),
|
64
61
|
# embedder settings
|
65
62
|
embedding_model=(str, Field(description="Embedding model: i.e. 'HuggingFaceEmbeddings', etc.", default="HuggingFaceEmbeddings")),
|
66
63
|
embedding_model_params=(dict, Field(description="Embedding model parameters: i.e. `{'model_name': 'sentence-transformers/all-MiniLM-L6-v2'}", default={"model_name": "sentence-transformers/all-MiniLM-L6-v2"})),
|
@@ -3,8 +3,10 @@ from langchain_community.agent_toolkits.base import BaseToolkit
|
|
3
3
|
from .api_wrapper import ConfluenceAPIWrapper
|
4
4
|
from langchain_core.tools import BaseTool
|
5
5
|
from ..base.tool import BaseAction
|
6
|
-
from pydantic import create_model, BaseModel, ConfigDict, Field
|
6
|
+
from pydantic import create_model, BaseModel, ConfigDict, Field
|
7
7
|
from ..utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length, parse_list, check_connection_response
|
8
|
+
from ...configurations.confluence import ConfluenceConfiguration
|
9
|
+
from ...configurations.pgvector import PgVectorConfiguration
|
8
10
|
import requests
|
9
11
|
|
10
12
|
name = "confluence"
|
@@ -15,9 +17,9 @@ def get_tools(tool):
|
|
15
17
|
base_url=tool['settings']['base_url'],
|
16
18
|
space=tool['settings'].get('space', None),
|
17
19
|
cloud=tool['settings'].get('cloud', True),
|
18
|
-
api_key=tool['settings'].get('api_key', None),
|
19
|
-
username=tool['settings'].get('username', None),
|
20
|
-
token=tool['settings'].get('token', None),
|
20
|
+
api_key=tool['settings'].get('confluence_configuration', {}).get('api_key', None),
|
21
|
+
username=tool['settings'].get('confluence_configuration', {}).get('username', None),
|
22
|
+
token=tool['settings'].get('confluence_configuration', {}).get('token', None),
|
21
23
|
limit=tool['settings'].get('limit', 5),
|
22
24
|
labels=parse_list(tool['settings'].get('labels', None)),
|
23
25
|
additional_fields=tool['settings'].get('additional_fields', []),
|
@@ -26,7 +28,7 @@ def get_tools(tool):
|
|
26
28
|
llm=tool['settings'].get('llm', None),
|
27
29
|
toolkit_name=tool.get('toolkit_name'),
|
28
30
|
# indexer settings
|
29
|
-
connection_string = tool['settings'].get('connection_string', None),
|
31
|
+
connection_string = tool['settings'].get('pgvector_configuration', {}).get('connection_string', None),
|
30
32
|
collection_name=str(tool['toolkit_name']),
|
31
33
|
doctype='doc',
|
32
34
|
embedding_model="HuggingFaceEmbeddings",
|
@@ -50,10 +52,15 @@ class ConfluenceToolkit(BaseToolkit):
|
|
50
52
|
url = self.base_url.rstrip('/') + '/wiki/rest/api/space'
|
51
53
|
headers = {'Accept': 'application/json'}
|
52
54
|
auth = None
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
confluence_config = self.confluence_configuration or {}
|
56
|
+
token = confluence_config.get('token')
|
57
|
+
username = confluence_config.get('username')
|
58
|
+
api_key = confluence_config.get('api_key')
|
59
|
+
|
60
|
+
if token:
|
61
|
+
headers['Authorization'] = f'Bearer {token}'
|
62
|
+
elif username and api_key:
|
63
|
+
auth = (username, api_key)
|
57
64
|
else:
|
58
65
|
raise ValueError('Confluence connection requires either token or username+api_key')
|
59
66
|
response = requests.get(url, headers=headers, auth=auth, timeout=5, verify=getattr(self, 'verify_ssl', True))
|
@@ -62,9 +69,6 @@ class ConfluenceToolkit(BaseToolkit):
|
|
62
69
|
model = create_model(
|
63
70
|
name,
|
64
71
|
base_url=(str, Field(description="Confluence URL", json_schema_extra={'configuration': True, 'configuration_title': True})),
|
65
|
-
token=(SecretStr, Field(description="Token", default=None, json_schema_extra={'secret': True, 'configuration': True})),
|
66
|
-
api_key=(SecretStr, Field(description="API key", default=None, json_schema_extra={'secret': True, 'configuration': True})),
|
67
|
-
username=(str, Field(description="Username", default=None, json_schema_extra={'configuration': True})),
|
68
72
|
space=(str, Field(description="Space", json_schema_extra={'toolkit_name': True,
|
69
73
|
'max_toolkit_length': ConfluenceToolkit.toolkit_max_length})),
|
70
74
|
cloud=(bool, Field(description="Hosting Option", json_schema_extra={'configuration': True})),
|
@@ -78,17 +82,13 @@ class ConfluenceToolkit(BaseToolkit):
|
|
78
82
|
number_of_retries=(int, Field(description="Number of retries", default=2)),
|
79
83
|
min_retry_seconds=(int, Field(description="Min retry, sec", default=10)),
|
80
84
|
max_retry_seconds=(int, Field(description="Max retry, sec", default=60)),
|
81
|
-
|
82
|
-
|
83
|
-
# indexer settings
|
84
|
-
connection_string = (Optional[SecretStr], Field(description="Connection string for vectorstore",
|
85
|
-
default=None,
|
86
|
-
json_schema_extra={'secret': True})),
|
87
|
-
|
88
|
-
# embedder settings
|
85
|
+
confluence_configuration=(Optional[ConfluenceConfiguration], Field(description="Confluence Configuration", json_schema_extra={'configuration_types': ['confluence']})),
|
86
|
+
pgvector_configuration=(Optional[PgVectorConfiguration], Field(description="PgVector Configuration", json_schema_extra={'configuration_types': ['pgvector']})),
|
89
87
|
embedding_model=(str, Field(description="Embedding model: i.e. 'HuggingFaceEmbeddings', etc.", default="HuggingFaceEmbeddings")),
|
90
88
|
embedding_model_params=(dict, Field(description="Embedding model parameters: i.e. `{'model_name': 'sentence-transformers/all-MiniLM-L6-v2'}", default={"model_name": "sentence-transformers/all-MiniLM-L6-v2"})),
|
91
89
|
|
90
|
+
selected_tools=(List[Literal[tuple(selected_tools)]],
|
91
|
+
Field(default=[], json_schema_extra={'args_schemas': selected_tools})),
|
92
92
|
__config__=ConfigDict(json_schema_extra={
|
93
93
|
'metadata': {
|
94
94
|
"label": "Confluence",
|
@@ -214,8 +214,11 @@ class ConfluenceAPIWrapper(BaseVectorStoreToolApiWrapper):
|
|
214
214
|
"`atlassian` package not found, please run "
|
215
215
|
"`pip install atlassian-python-api`"
|
216
216
|
)
|
217
|
-
|
217
|
+
if not values.get('base_url'):
|
218
|
+
raise ValueError("Base URL is required for Confluence API Wrapper.")
|
218
219
|
url = values['base_url']
|
220
|
+
if not (values.get('token') or (values.get('api_key') and values.get('username'))):
|
221
|
+
raise ValueError("Either 'token' or both 'api_key' and 'username' must be provided for authentication.")
|
219
222
|
api_key = values.get('api_key')
|
220
223
|
username = values.get('username')
|
221
224
|
token = values.get('token')
|
@@ -844,8 +847,12 @@ class ConfluenceAPIWrapper(BaseVectorStoreToolApiWrapper):
|
|
844
847
|
yield document
|
845
848
|
|
846
849
|
def _process_document(self, document: Document) -> Generator[Document, None, None]:
|
847
|
-
|
848
|
-
|
850
|
+
attachments = self.get_page_attachments(document.metadata.get('id'))
|
851
|
+
if isinstance(attachments, str):
|
852
|
+
logger.info(f" {document.metadata.get('id')}: {attachments}")
|
853
|
+
return
|
854
|
+
for attachment in attachments:
|
855
|
+
yield Document(page_content=attachment.get('content', '') or attachment.get('llm_analysis', ''), metadata=attachment.get('metadata', {}))
|
849
856
|
|
850
857
|
def _download_image(self, image_url):
|
851
858
|
"""
|
@@ -1577,7 +1584,7 @@ class ConfluenceAPIWrapper(BaseVectorStoreToolApiWrapper):
|
|
1577
1584
|
"""Return the parameters for indexing data."""
|
1578
1585
|
return {
|
1579
1586
|
"content_format": (Literal['view', 'storage', 'export_view', 'editor', 'anonymous'],
|
1580
|
-
Field(description="The format of the content to be retrieved.")),
|
1587
|
+
Field(description="The format of the content to be retrieved.", default='view')),
|
1581
1588
|
"page_ids": (Optional[List[str]], Field(description="List of page IDs to retrieve.", default=None)),
|
1582
1589
|
"label": (Optional[str], Field(description="Label to filter pages.", default=None)),
|
1583
1590
|
"cql": (Optional[str], Field(description="CQL query to filter pages.", default=None)),
|
alita_sdk/tools/elitea_base.py
CHANGED
@@ -374,7 +374,7 @@ class BaseVectorStoreToolApiWrapper(BaseToolApiWrapper):
|
|
374
374
|
def list_collections(self):
|
375
375
|
"""Lists all collections in the vector store."""
|
376
376
|
vectorstore_wrapper = self._init_vector_store()
|
377
|
-
return self._adapter.list_collections(vectorstore_wrapper)
|
377
|
+
return self._adapter.list_collections(vectorstore_wrapper, self.collection_name or "")
|
378
378
|
|
379
379
|
def search_index(self,
|
380
380
|
query: str,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Dict, List, Optional, Literal
|
1
|
+
from typing import Dict, List, Optional, Literal
|
2
2
|
|
3
3
|
from langchain_core.tools import BaseTool, BaseToolkit
|
4
4
|
from pydantic import create_model, BaseModel, ConfigDict, Field, SecretStr
|
@@ -7,6 +7,8 @@ from .api_wrapper import AlitaGitHubAPIWrapper
|
|
7
7
|
from .tool import GitHubAction
|
8
8
|
|
9
9
|
from ..utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length
|
10
|
+
from ...configurations.github import GithubConfiguration
|
11
|
+
from ...configurations.pgvector import PgVectorConfiguration
|
10
12
|
|
11
13
|
name = "github"
|
12
14
|
|
@@ -17,14 +19,14 @@ def _get_toolkit(tool) -> BaseToolkit:
|
|
17
19
|
github_repository=tool['settings']['repository'],
|
18
20
|
active_branch=tool['settings']['active_branch'],
|
19
21
|
github_base_branch=tool['settings']['base_branch'],
|
20
|
-
github_access_token=tool['settings'].get('access_token', ''),
|
21
|
-
github_username=tool['settings'].get('username', ''),
|
22
|
-
github_password=tool['settings'].get('password', ''),
|
23
|
-
github_app_id=tool['settings'].get('app_id', None),
|
24
|
-
github_app_private_key=tool['settings'].get('app_private_key', None),
|
22
|
+
github_access_token=tool['settings'].get('github_configuration', {}).get('access_token', ''),
|
23
|
+
github_username=tool['settings'].get('github_configuration', {}).get('username', ''),
|
24
|
+
github_password=tool['settings'].get('github_configuration', {}).get('password', ''),
|
25
|
+
github_app_id=tool['settings'].get('github_configuration', {}).get('app_id', None),
|
26
|
+
github_app_private_key=tool['settings'].get('github_configuration', {}).get('app_private_key', None),
|
25
27
|
llm=tool['settings'].get('llm', None),
|
26
28
|
alita=tool['settings'].get('alita', None),
|
27
|
-
connection_string=tool['settings'].get('connection_string', None),
|
29
|
+
connection_string=tool['settings'].get('pgvector_configuration', {}).get('connection_string', None),
|
28
30
|
collection_name=str(tool['toolkit_name']),
|
29
31
|
doctype='code',
|
30
32
|
embedding_model="HuggingFaceEmbeddings",
|
@@ -45,7 +47,8 @@ class AlitaGitHubToolkit(BaseToolkit):
|
|
45
47
|
|
46
48
|
@staticmethod
|
47
49
|
def toolkit_config_schema() -> BaseModel:
|
48
|
-
selected_tools = {x['name']: x['args_schema'].schema() for x in
|
50
|
+
selected_tools = {x['name']: x['args_schema'].schema() for x in
|
51
|
+
AlitaGitHubAPIWrapper.model_construct().get_available_tools()}
|
49
52
|
AlitaGitHubToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
|
50
53
|
return create_model(
|
51
54
|
name,
|
@@ -54,53 +57,27 @@ class AlitaGitHubToolkit(BaseToolkit):
|
|
54
57
|
'metadata': {
|
55
58
|
"label": "GitHub",
|
56
59
|
"icon_url": None,
|
57
|
-
"sections": {
|
58
|
-
"auth": {
|
59
|
-
"required": False,
|
60
|
-
"subsections": [
|
61
|
-
{
|
62
|
-
"name": "Token",
|
63
|
-
"fields": ["access_token"]
|
64
|
-
},
|
65
|
-
{
|
66
|
-
"name": "Password",
|
67
|
-
"fields": ["username", "password"]
|
68
|
-
},
|
69
|
-
{
|
70
|
-
"name": "App private key",
|
71
|
-
"fields": ["app_id", "app_private_key"]
|
72
|
-
}
|
73
|
-
]
|
74
|
-
},
|
75
|
-
},
|
76
60
|
"categories": ["code repositories"],
|
77
61
|
"extra_categories": ["github", "git", "repository", "code", "version control"],
|
78
62
|
},
|
79
63
|
}
|
80
64
|
),
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
username=(Optional[str], Field(description="Github Username", default=None, json_schema_extra={'configuration': True})),
|
88
|
-
password=(Optional[SecretStr], Field(description="Github Password", default=None, json_schema_extra={'secret': True, 'configuration': True})),
|
89
|
-
|
90
|
-
repository=(str, Field(description="Github repository", json_schema_extra={'toolkit_name': True, 'max_toolkit_length': AlitaGitHubToolkit.toolkit_max_length})),
|
65
|
+
github_configuration=(Optional[GithubConfiguration], Field(description="Github configuration", default=None,
|
66
|
+
json_schema_extra={'configuration_types': ['github']})),
|
67
|
+
pgvector_configuration=(Optional[PgVectorConfiguration], Field(description="PgVector configuration", default=None,
|
68
|
+
json_schema_extra={'configuration_types': ['pgvector']})),
|
69
|
+
repository=(str, Field(description="Github repository", json_schema_extra={'toolkit_name': True,
|
70
|
+
'max_toolkit_length': AlitaGitHubToolkit.toolkit_max_length})),
|
91
71
|
active_branch=(Optional[str], Field(description="Active branch", default="main")),
|
92
72
|
base_branch=(Optional[str], Field(description="Github Base branch", default="main")),
|
93
|
-
|
94
73
|
# indexer settings
|
95
|
-
connection_string
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
# embedder settings
|
74
|
+
connection_string=(Optional[SecretStr], Field(description="Connection string for vectorstore",
|
75
|
+
default=None,
|
76
|
+
json_schema_extra={'secret': True})),
|
100
77
|
embedding_model=(str, Field(description="Embedding model: i.e. 'HuggingFaceEmbeddings', etc.", default="HuggingFaceEmbeddings")),
|
101
78
|
embedding_model_params=(dict, Field(description="Embedding model parameters: i.e. `{'model_name': 'sentence-transformers/all-MiniLM-L6-v2'}", default={"model_name": "sentence-transformers/all-MiniLM-L6-v2"})),
|
102
|
-
|
103
|
-
|
79
|
+
selected_tools=(List[Literal[tuple(selected_tools)]],
|
80
|
+
Field(default=[], json_schema_extra={'args_schemas': selected_tools}))
|
104
81
|
)
|
105
82
|
|
106
83
|
@classmethod
|
@@ -3,11 +3,13 @@ from typing import Dict, List, Literal, Optional
|
|
3
3
|
from alita_sdk.tools.base.tool import BaseAction
|
4
4
|
from langchain_core.tools import BaseTool
|
5
5
|
from langchain_core.tools import BaseToolkit
|
6
|
-
from pydantic import create_model, BaseModel, ConfigDict
|
6
|
+
from pydantic import create_model, BaseModel, ConfigDict
|
7
7
|
from pydantic.fields import Field
|
8
8
|
|
9
9
|
from .api_wrapper import GitLabAPIWrapper
|
10
10
|
from ..utils import clean_string, TOOLKIT_SPLITTER, get_max_toolkit_length
|
11
|
+
from ...configurations.gitlab import GitlabConfiguration
|
12
|
+
from ...configurations.pgvector import PgVectorConfiguration
|
11
13
|
|
12
14
|
name = "gitlab"
|
13
15
|
|
@@ -18,11 +20,11 @@ def get_tools(tool):
|
|
18
20
|
url=tool['settings']['url'],
|
19
21
|
repository=tool['settings']['repository'],
|
20
22
|
branch=tool['settings']['branch'],
|
21
|
-
private_token=tool['settings']
|
23
|
+
private_token=tool['settings'].get('gitlab_configuration', {}).get('private_token', ''),
|
22
24
|
|
23
25
|
llm=tool['settings'].get('llm', None),
|
24
26
|
alita=tool['settings'].get('alita', None),
|
25
|
-
connection_string=tool['settings'].get('connection_string', None),
|
27
|
+
connection_string=tool['settings'].get('pgvector_configuration', {}).get('connection_string', None),
|
26
28
|
collection_name=str(tool['toolkit_name']),
|
27
29
|
doctype='code',
|
28
30
|
embedding_model="HuggingFaceEmbeddings",
|
@@ -44,13 +46,11 @@ class AlitaGitlabToolkit(BaseToolkit):
|
|
44
46
|
name,
|
45
47
|
url=(str, Field(description="GitLab URL", json_schema_extra={'configuration': True, 'configuration_title': True})),
|
46
48
|
repository=(str, Field(description="GitLab repository", json_schema_extra={'toolkit_name': True, 'max_toolkit_length': AlitaGitlabToolkit.toolkit_max_length})),
|
47
|
-
|
49
|
+
gitlab_configuration=(Optional[GitlabConfiguration], Field(description="GitLab configuration", json_schema_extra={'configuration_types': ['gitlab']})),
|
48
50
|
branch=(str, Field(description="Main branch", default="main")),
|
49
51
|
# indexer settings
|
50
|
-
|
51
|
-
|
52
|
-
json_schema_extra={'secret': True})),
|
53
|
-
|
52
|
+
pgvector_configuration=(Optional[PgVectorConfiguration], Field(description="PgVector configuration", default=None,
|
53
|
+
json_schema_extra={'configuration_types': ['pgvector']})),
|
54
54
|
# embedder settings
|
55
55
|
embedding_model=(str, Field(description="Embedding model: i.e. 'HuggingFaceEmbeddings', etc.", default="HuggingFaceEmbeddings")),
|
56
56
|
embedding_model_params=(dict, Field(description="Embedding model parameters: i.e. `{'model_name': 'sentence-transformers/all-MiniLM-L6-v2'}", default={"model_name": "sentence-transformers/all-MiniLM-L6-v2"})),
|