Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/alita_tools/confluence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class ConfluenceToolkit(BaseToolkit):

@staticmethod
def toolkit_config_schema() -> BaseModel:
wrapper = ConfluenceAPIWrapper.model_construct()
selected_tools = {x['name']: x['args_schema'].schema() for x in
ConfluenceAPIWrapper.model_construct().get_available_tools()}
ConfluenceToolkit.toolkit_max_length = get_max_toolkit_length(selected_tools)
wrapper.get_available_tools()}
return create_model(
name,
base_url=(str, Field(description="Confluence URL", json_schema_extra={'configuration': True, 'configuration_title': True})),
token=(SecretStr, Field(description="Token", default=None, json_schema_extra={'secret': True, 'configuration': True})),
api_key=(SecretStr, Field(description="API key", default=None, json_schema_extra={'secret': True, 'configuration': True})),
username=(str, Field(description="Username", default=None, json_schema_extra={'configuration': True})),
space=(str, Field(description="Space", default=None, json_schema_extra={'toolkit_name': True,
'max_toolkit_length': ConfluenceToolkit.toolkit_max_length})),
'max_toolkit_length': wrapper.get_max_toolkit_length()})),
cloud=(bool, Field(description="Hosting Option", json_schema_extra={'configuration': True})),
limit=(int, Field(description="Pages limit per request", default=5)),
labels=(Optional[str], Field(
Expand Down Expand Up @@ -85,7 +85,7 @@ def get_toolkit(cls, selected_tools: list[str] | None = None, toolkit_name: Opti
if selected_tools is None:
selected_tools = []
confluence_api_wrapper = ConfluenceAPIWrapper(**kwargs)
prefix = clean_string(toolkit_name, ConfluenceToolkit.toolkit_max_length) + TOOLKIT_SPLITTER if toolkit_name else ''
prefix = clean_string(toolkit_name, confluence_api_wrapper.get_max_toolkit_length()) + TOOLKIT_SPLITTER if toolkit_name else ''
available_tools = confluence_api_wrapper.get_available_tools()
tools = []
for tool in available_tools:
Expand Down
7 changes: 6 additions & 1 deletion src/alita_tools/elitea_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from typing import Any, Optional, List
from pydantic import BaseModel, create_model, Field
from .utils import TOOLKIT_SPLITTER
from .utils import TOOLKIT_SPLITTER, get_max_toolkit_length

logger = logging.getLogger(__name__)

Expand All @@ -19,6 +19,11 @@

class BaseToolApiWrapper(BaseModel):

def get_max_toolkit_length(self):
"""Calculates the maximum length of the toolkit name based on the selected tools per toolkit."""
return get_max_toolkit_length({x['name']: x['args_schema'].schema() for x in
self.get_available_tools()})

def get_available_tools(self):
raise NotImplementedError("Subclasses should implement this method")

Expand Down