alita-sdk 0.3.257__py3-none-any.whl → 0.3.584__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.
Potentially problematic release.
This version of alita-sdk might be problematic. Click here for more details.
- alita_sdk/cli/__init__.py +10 -0
- alita_sdk/cli/__main__.py +17 -0
- alita_sdk/cli/agent/__init__.py +5 -0
- alita_sdk/cli/agent/default.py +258 -0
- alita_sdk/cli/agent_executor.py +155 -0
- alita_sdk/cli/agent_loader.py +215 -0
- alita_sdk/cli/agent_ui.py +228 -0
- alita_sdk/cli/agents.py +3794 -0
- alita_sdk/cli/callbacks.py +647 -0
- alita_sdk/cli/cli.py +168 -0
- alita_sdk/cli/config.py +306 -0
- alita_sdk/cli/context/__init__.py +30 -0
- alita_sdk/cli/context/cleanup.py +198 -0
- alita_sdk/cli/context/manager.py +731 -0
- alita_sdk/cli/context/message.py +285 -0
- alita_sdk/cli/context/strategies.py +289 -0
- alita_sdk/cli/context/token_estimation.py +127 -0
- alita_sdk/cli/formatting.py +182 -0
- alita_sdk/cli/input_handler.py +419 -0
- alita_sdk/cli/inventory.py +1073 -0
- alita_sdk/cli/mcp_loader.py +315 -0
- alita_sdk/cli/toolkit.py +327 -0
- alita_sdk/cli/toolkit_loader.py +85 -0
- alita_sdk/cli/tools/__init__.py +43 -0
- alita_sdk/cli/tools/approval.py +224 -0
- alita_sdk/cli/tools/filesystem.py +1751 -0
- alita_sdk/cli/tools/planning.py +389 -0
- alita_sdk/cli/tools/terminal.py +414 -0
- alita_sdk/community/__init__.py +72 -12
- alita_sdk/community/inventory/__init__.py +236 -0
- alita_sdk/community/inventory/config.py +257 -0
- alita_sdk/community/inventory/enrichment.py +2137 -0
- alita_sdk/community/inventory/extractors.py +1469 -0
- alita_sdk/community/inventory/ingestion.py +3172 -0
- alita_sdk/community/inventory/knowledge_graph.py +1457 -0
- alita_sdk/community/inventory/parsers/__init__.py +218 -0
- alita_sdk/community/inventory/parsers/base.py +295 -0
- alita_sdk/community/inventory/parsers/csharp_parser.py +907 -0
- alita_sdk/community/inventory/parsers/go_parser.py +851 -0
- alita_sdk/community/inventory/parsers/html_parser.py +389 -0
- alita_sdk/community/inventory/parsers/java_parser.py +593 -0
- alita_sdk/community/inventory/parsers/javascript_parser.py +629 -0
- alita_sdk/community/inventory/parsers/kotlin_parser.py +768 -0
- alita_sdk/community/inventory/parsers/markdown_parser.py +362 -0
- alita_sdk/community/inventory/parsers/python_parser.py +604 -0
- alita_sdk/community/inventory/parsers/rust_parser.py +858 -0
- alita_sdk/community/inventory/parsers/swift_parser.py +832 -0
- alita_sdk/community/inventory/parsers/text_parser.py +322 -0
- alita_sdk/community/inventory/parsers/yaml_parser.py +370 -0
- alita_sdk/community/inventory/patterns/__init__.py +61 -0
- alita_sdk/community/inventory/patterns/ast_adapter.py +380 -0
- alita_sdk/community/inventory/patterns/loader.py +348 -0
- alita_sdk/community/inventory/patterns/registry.py +198 -0
- alita_sdk/community/inventory/presets.py +535 -0
- alita_sdk/community/inventory/retrieval.py +1403 -0
- alita_sdk/community/inventory/toolkit.py +173 -0
- alita_sdk/community/inventory/toolkit_utils.py +176 -0
- alita_sdk/community/inventory/visualize.py +1370 -0
- alita_sdk/configurations/__init__.py +11 -0
- alita_sdk/configurations/ado.py +148 -2
- alita_sdk/configurations/azure_search.py +1 -1
- alita_sdk/configurations/bigquery.py +1 -1
- alita_sdk/configurations/bitbucket.py +94 -2
- alita_sdk/configurations/browser.py +18 -0
- alita_sdk/configurations/carrier.py +19 -0
- alita_sdk/configurations/confluence.py +130 -1
- alita_sdk/configurations/delta_lake.py +1 -1
- alita_sdk/configurations/figma.py +76 -5
- alita_sdk/configurations/github.py +65 -1
- alita_sdk/configurations/gitlab.py +81 -0
- alita_sdk/configurations/google_places.py +17 -0
- alita_sdk/configurations/jira.py +103 -0
- alita_sdk/configurations/openapi.py +323 -0
- alita_sdk/configurations/postman.py +1 -1
- alita_sdk/configurations/qtest.py +72 -3
- alita_sdk/configurations/report_portal.py +115 -0
- alita_sdk/configurations/salesforce.py +19 -0
- alita_sdk/configurations/service_now.py +1 -12
- alita_sdk/configurations/sharepoint.py +167 -0
- alita_sdk/configurations/sonar.py +18 -0
- alita_sdk/configurations/sql.py +20 -0
- alita_sdk/configurations/testio.py +101 -0
- alita_sdk/configurations/testrail.py +88 -0
- alita_sdk/configurations/xray.py +94 -1
- alita_sdk/configurations/zephyr_enterprise.py +94 -1
- alita_sdk/configurations/zephyr_essential.py +95 -0
- alita_sdk/runtime/clients/artifact.py +21 -4
- alita_sdk/runtime/clients/client.py +458 -67
- alita_sdk/runtime/clients/mcp_discovery.py +342 -0
- alita_sdk/runtime/clients/mcp_manager.py +262 -0
- alita_sdk/runtime/clients/sandbox_client.py +352 -0
- alita_sdk/runtime/langchain/_constants_bkup.py +1318 -0
- alita_sdk/runtime/langchain/assistant.py +183 -43
- alita_sdk/runtime/langchain/constants.py +647 -1
- alita_sdk/runtime/langchain/document_loaders/AlitaDocxMammothLoader.py +315 -3
- alita_sdk/runtime/langchain/document_loaders/AlitaExcelLoader.py +209 -31
- alita_sdk/runtime/langchain/document_loaders/AlitaImageLoader.py +1 -1
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLinesLoader.py +77 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py +10 -3
- alita_sdk/runtime/langchain/document_loaders/AlitaMarkdownLoader.py +66 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaPDFLoader.py +79 -10
- alita_sdk/runtime/langchain/document_loaders/AlitaPowerPointLoader.py +52 -15
- alita_sdk/runtime/langchain/document_loaders/AlitaPythonLoader.py +9 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaTableLoader.py +1 -4
- alita_sdk/runtime/langchain/document_loaders/AlitaTextLoader.py +15 -2
- alita_sdk/runtime/langchain/document_loaders/ImageParser.py +30 -0
- alita_sdk/runtime/langchain/document_loaders/constants.py +189 -41
- alita_sdk/runtime/langchain/interfaces/llm_processor.py +4 -2
- alita_sdk/runtime/langchain/langraph_agent.py +493 -105
- alita_sdk/runtime/langchain/utils.py +118 -8
- alita_sdk/runtime/llms/preloaded.py +2 -6
- alita_sdk/runtime/models/mcp_models.py +61 -0
- alita_sdk/runtime/skills/__init__.py +91 -0
- alita_sdk/runtime/skills/callbacks.py +498 -0
- alita_sdk/runtime/skills/discovery.py +540 -0
- alita_sdk/runtime/skills/executor.py +610 -0
- alita_sdk/runtime/skills/input_builder.py +371 -0
- alita_sdk/runtime/skills/models.py +330 -0
- alita_sdk/runtime/skills/registry.py +355 -0
- alita_sdk/runtime/skills/skill_runner.py +330 -0
- alita_sdk/runtime/toolkits/__init__.py +28 -0
- alita_sdk/runtime/toolkits/application.py +14 -4
- alita_sdk/runtime/toolkits/artifact.py +25 -9
- alita_sdk/runtime/toolkits/datasource.py +13 -6
- alita_sdk/runtime/toolkits/mcp.py +782 -0
- alita_sdk/runtime/toolkits/planning.py +178 -0
- alita_sdk/runtime/toolkits/skill_router.py +238 -0
- alita_sdk/runtime/toolkits/subgraph.py +11 -6
- alita_sdk/runtime/toolkits/tools.py +314 -70
- alita_sdk/runtime/toolkits/vectorstore.py +11 -5
- alita_sdk/runtime/tools/__init__.py +24 -0
- alita_sdk/runtime/tools/application.py +16 -4
- alita_sdk/runtime/tools/artifact.py +367 -33
- alita_sdk/runtime/tools/data_analysis.py +183 -0
- alita_sdk/runtime/tools/function.py +100 -4
- alita_sdk/runtime/tools/graph.py +81 -0
- alita_sdk/runtime/tools/image_generation.py +218 -0
- alita_sdk/runtime/tools/llm.py +1032 -177
- alita_sdk/runtime/tools/loop.py +3 -1
- alita_sdk/runtime/tools/loop_output.py +3 -1
- alita_sdk/runtime/tools/mcp_inspect_tool.py +284 -0
- alita_sdk/runtime/tools/mcp_remote_tool.py +181 -0
- alita_sdk/runtime/tools/mcp_server_tool.py +3 -1
- alita_sdk/runtime/tools/planning/__init__.py +36 -0
- alita_sdk/runtime/tools/planning/models.py +246 -0
- alita_sdk/runtime/tools/planning/wrapper.py +607 -0
- alita_sdk/runtime/tools/router.py +2 -1
- alita_sdk/runtime/tools/sandbox.py +375 -0
- alita_sdk/runtime/tools/skill_router.py +776 -0
- alita_sdk/runtime/tools/tool.py +3 -1
- alita_sdk/runtime/tools/vectorstore.py +69 -65
- alita_sdk/runtime/tools/vectorstore_base.py +163 -90
- alita_sdk/runtime/utils/AlitaCallback.py +137 -21
- alita_sdk/runtime/utils/constants.py +5 -1
- alita_sdk/runtime/utils/mcp_client.py +492 -0
- alita_sdk/runtime/utils/mcp_oauth.py +361 -0
- alita_sdk/runtime/utils/mcp_sse_client.py +434 -0
- alita_sdk/runtime/utils/mcp_tools_discovery.py +124 -0
- alita_sdk/runtime/utils/streamlit.py +41 -14
- alita_sdk/runtime/utils/toolkit_utils.py +28 -9
- alita_sdk/runtime/utils/utils.py +48 -0
- alita_sdk/tools/__init__.py +135 -37
- alita_sdk/tools/ado/__init__.py +2 -2
- alita_sdk/tools/ado/repos/__init__.py +16 -19
- alita_sdk/tools/ado/repos/repos_wrapper.py +12 -20
- alita_sdk/tools/ado/test_plan/__init__.py +27 -8
- alita_sdk/tools/ado/test_plan/test_plan_wrapper.py +56 -28
- alita_sdk/tools/ado/wiki/__init__.py +28 -12
- alita_sdk/tools/ado/wiki/ado_wrapper.py +114 -40
- alita_sdk/tools/ado/work_item/__init__.py +28 -12
- alita_sdk/tools/ado/work_item/ado_wrapper.py +95 -11
- alita_sdk/tools/advanced_jira_mining/__init__.py +13 -8
- alita_sdk/tools/aws/delta_lake/__init__.py +15 -11
- alita_sdk/tools/aws/delta_lake/tool.py +5 -1
- alita_sdk/tools/azure_ai/search/__init__.py +14 -8
- alita_sdk/tools/base/tool.py +5 -1
- alita_sdk/tools/base_indexer_toolkit.py +454 -110
- alita_sdk/tools/bitbucket/__init__.py +28 -19
- alita_sdk/tools/bitbucket/api_wrapper.py +285 -27
- alita_sdk/tools/bitbucket/cloud_api_wrapper.py +5 -5
- alita_sdk/tools/browser/__init__.py +41 -16
- alita_sdk/tools/browser/crawler.py +3 -1
- alita_sdk/tools/browser/utils.py +15 -6
- alita_sdk/tools/carrier/__init__.py +18 -17
- alita_sdk/tools/carrier/backend_reports_tool.py +8 -4
- alita_sdk/tools/carrier/excel_reporter.py +8 -4
- alita_sdk/tools/chunkers/__init__.py +3 -1
- alita_sdk/tools/chunkers/code/codeparser.py +1 -1
- alita_sdk/tools/chunkers/sematic/json_chunker.py +2 -1
- alita_sdk/tools/chunkers/sematic/markdown_chunker.py +97 -6
- alita_sdk/tools/chunkers/sematic/proposal_chunker.py +1 -1
- alita_sdk/tools/chunkers/universal_chunker.py +270 -0
- alita_sdk/tools/cloud/aws/__init__.py +12 -7
- alita_sdk/tools/cloud/azure/__init__.py +12 -7
- alita_sdk/tools/cloud/gcp/__init__.py +12 -7
- alita_sdk/tools/cloud/k8s/__init__.py +12 -7
- alita_sdk/tools/code/linter/__init__.py +10 -8
- alita_sdk/tools/code/loaders/codesearcher.py +3 -2
- alita_sdk/tools/code/sonar/__init__.py +21 -13
- alita_sdk/tools/code_indexer_toolkit.py +199 -0
- alita_sdk/tools/confluence/__init__.py +22 -14
- alita_sdk/tools/confluence/api_wrapper.py +197 -58
- alita_sdk/tools/confluence/loader.py +14 -2
- alita_sdk/tools/custom_open_api/__init__.py +12 -5
- alita_sdk/tools/elastic/__init__.py +11 -8
- alita_sdk/tools/elitea_base.py +546 -64
- alita_sdk/tools/figma/__init__.py +60 -11
- alita_sdk/tools/figma/api_wrapper.py +1400 -167
- alita_sdk/tools/figma/figma_client.py +73 -0
- alita_sdk/tools/figma/toon_tools.py +2748 -0
- alita_sdk/tools/github/__init__.py +18 -17
- alita_sdk/tools/github/api_wrapper.py +9 -26
- alita_sdk/tools/github/github_client.py +81 -12
- alita_sdk/tools/github/schemas.py +2 -1
- alita_sdk/tools/github/tool.py +5 -1
- alita_sdk/tools/gitlab/__init__.py +19 -13
- alita_sdk/tools/gitlab/api_wrapper.py +256 -80
- alita_sdk/tools/gitlab_org/__init__.py +14 -10
- alita_sdk/tools/google/bigquery/__init__.py +14 -13
- alita_sdk/tools/google/bigquery/tool.py +5 -1
- alita_sdk/tools/google_places/__init__.py +21 -11
- alita_sdk/tools/jira/__init__.py +22 -11
- alita_sdk/tools/jira/api_wrapper.py +315 -168
- alita_sdk/tools/keycloak/__init__.py +11 -8
- alita_sdk/tools/localgit/__init__.py +9 -3
- alita_sdk/tools/localgit/local_git.py +62 -54
- alita_sdk/tools/localgit/tool.py +5 -1
- alita_sdk/tools/memory/__init__.py +38 -14
- alita_sdk/tools/non_code_indexer_toolkit.py +7 -2
- alita_sdk/tools/ocr/__init__.py +11 -8
- alita_sdk/tools/openapi/__init__.py +491 -106
- alita_sdk/tools/openapi/api_wrapper.py +1357 -0
- alita_sdk/tools/openapi/tool.py +20 -0
- alita_sdk/tools/pandas/__init__.py +20 -12
- alita_sdk/tools/pandas/api_wrapper.py +40 -45
- alita_sdk/tools/pandas/dataframe/generator/base.py +3 -1
- alita_sdk/tools/postman/__init__.py +11 -11
- alita_sdk/tools/postman/api_wrapper.py +19 -8
- alita_sdk/tools/postman/postman_analysis.py +8 -1
- alita_sdk/tools/pptx/__init__.py +11 -10
- alita_sdk/tools/qtest/__init__.py +22 -14
- alita_sdk/tools/qtest/api_wrapper.py +1784 -88
- alita_sdk/tools/rally/__init__.py +13 -10
- alita_sdk/tools/report_portal/__init__.py +23 -16
- alita_sdk/tools/salesforce/__init__.py +22 -16
- alita_sdk/tools/servicenow/__init__.py +21 -16
- alita_sdk/tools/servicenow/api_wrapper.py +1 -1
- alita_sdk/tools/sharepoint/__init__.py +17 -14
- alita_sdk/tools/sharepoint/api_wrapper.py +179 -39
- alita_sdk/tools/sharepoint/authorization_helper.py +191 -1
- alita_sdk/tools/sharepoint/utils.py +8 -2
- alita_sdk/tools/slack/__init__.py +13 -8
- alita_sdk/tools/sql/__init__.py +22 -19
- alita_sdk/tools/sql/api_wrapper.py +71 -23
- alita_sdk/tools/testio/__init__.py +21 -13
- alita_sdk/tools/testrail/__init__.py +13 -11
- alita_sdk/tools/testrail/api_wrapper.py +214 -46
- alita_sdk/tools/utils/__init__.py +28 -4
- alita_sdk/tools/utils/content_parser.py +241 -55
- alita_sdk/tools/utils/text_operations.py +254 -0
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +83 -27
- alita_sdk/tools/xray/__init__.py +18 -14
- alita_sdk/tools/xray/api_wrapper.py +58 -113
- alita_sdk/tools/yagmail/__init__.py +9 -3
- alita_sdk/tools/zephyr/__init__.py +12 -7
- alita_sdk/tools/zephyr_enterprise/__init__.py +16 -9
- alita_sdk/tools/zephyr_enterprise/api_wrapper.py +30 -15
- alita_sdk/tools/zephyr_essential/__init__.py +16 -10
- alita_sdk/tools/zephyr_essential/api_wrapper.py +297 -54
- alita_sdk/tools/zephyr_essential/client.py +6 -4
- alita_sdk/tools/zephyr_scale/__init__.py +13 -8
- alita_sdk/tools/zephyr_scale/api_wrapper.py +39 -31
- alita_sdk/tools/zephyr_squad/__init__.py +12 -7
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/METADATA +184 -37
- alita_sdk-0.3.584.dist-info/RECORD +452 -0
- alita_sdk-0.3.584.dist-info/entry_points.txt +2 -0
- alita_sdk/tools/bitbucket/tools.py +0 -304
- alita_sdk-0.3.257.dist-info/RECORD +0 -343
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.257.dist-info → alita_sdk-0.3.584.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ from typing import Any, Optional
|
|
|
5
5
|
from langchain.agents import (
|
|
6
6
|
AgentExecutor, create_openai_tools_agent,
|
|
7
7
|
create_json_chat_agent)
|
|
8
|
+
from langgraph.graph.state import CompiledStateGraph
|
|
8
9
|
from langgraph.store.base import BaseStore
|
|
9
10
|
from .agents.xml_chat import create_xml_chat_agent
|
|
10
11
|
from .langraph_agent import create_graph
|
|
@@ -12,10 +13,14 @@ from langchain_core.messages import (
|
|
|
12
13
|
BaseMessage, SystemMessage, HumanMessage
|
|
13
14
|
)
|
|
14
15
|
from langchain_core.prompts import MessagesPlaceholder
|
|
15
|
-
from .constants import REACT_ADDON, REACT_VARS, XML_ADDON
|
|
16
|
+
from .constants import (REACT_ADDON, REACT_VARS, XML_ADDON, USER_ADDON,
|
|
17
|
+
QA_ASSISTANT, NERDY_ASSISTANT, QUIRKY_ASSISTANT, CYNICAL_ASSISTANT,
|
|
18
|
+
DEFAULT_ASSISTANT, PLAN_ADDON, PYODITE_ADDON, DATA_ANALYSIS_ADDON,
|
|
19
|
+
SEARCH_INDEX_ADDON, FILE_HANDLING_INSTRUCTIONS)
|
|
16
20
|
from .chat_message_template import Jinja2TemplatedChatMessagesTemplate
|
|
17
21
|
from ..tools.echo import EchoTool
|
|
18
22
|
from langchain_core.tools import BaseTool, ToolException
|
|
23
|
+
from jinja2 import Environment, DebugUndefined
|
|
19
24
|
|
|
20
25
|
logger = logging.getLogger(__name__)
|
|
21
26
|
|
|
@@ -28,15 +33,23 @@ class Assistant:
|
|
|
28
33
|
app_type: str = "openai",
|
|
29
34
|
tools: Optional[list] = [],
|
|
30
35
|
memory: Optional[Any] = None,
|
|
31
|
-
store: Optional[BaseStore] = None
|
|
36
|
+
store: Optional[BaseStore] = None,
|
|
37
|
+
debug_mode: Optional[bool] = False,
|
|
38
|
+
mcp_tokens: Optional[dict] = None,
|
|
39
|
+
conversation_id: Optional[str] = None,
|
|
40
|
+
ignored_mcp_servers: Optional[list] = None,
|
|
41
|
+
persona: Optional[str] = "generic"):
|
|
32
42
|
|
|
33
43
|
self.app_type = app_type
|
|
34
44
|
self.memory = memory
|
|
35
45
|
self.store = store
|
|
46
|
+
self.persona = persona
|
|
47
|
+
self.max_iterations = data.get('meta', {}).get('step_limit', 25)
|
|
36
48
|
|
|
37
49
|
logger.debug("Data for agent creation: %s", data)
|
|
38
50
|
logger.info("App type: %s", app_type)
|
|
39
|
-
|
|
51
|
+
|
|
52
|
+
self.alita_client = alita
|
|
40
53
|
self.client = client
|
|
41
54
|
# For predict agents, use the client as-is since it's already configured
|
|
42
55
|
# if app_type == "predict":
|
|
@@ -61,11 +74,11 @@ class Assistant:
|
|
|
61
74
|
# )
|
|
62
75
|
# self.client = target_cls(**model_params)
|
|
63
76
|
# validate agents compatibility: non-pipeline agents cannot have pipelines as toolkits
|
|
64
|
-
if app_type not in ["pipeline", "predict"]:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
# if app_type not in ["pipeline", "predict"]:
|
|
78
|
+
# tools_to_check = data.get('tools', [])
|
|
79
|
+
# if any(tool['agent_type'] == 'pipeline' for tool in tools_to_check):
|
|
80
|
+
# raise ToolException("Non-pipeline agents cannot have pipelines as a toolkits. "
|
|
81
|
+
# "Review toolkits configuration or use pipeline as master agent.")
|
|
69
82
|
|
|
70
83
|
# configure memory store if memory tool is defined (not needed for predict agents)
|
|
71
84
|
if app_type != "predict":
|
|
@@ -74,13 +87,88 @@ class Assistant:
|
|
|
74
87
|
else:
|
|
75
88
|
# For predict agents, initialize memory store to None since they don't use memory
|
|
76
89
|
self.store = None
|
|
77
|
-
|
|
90
|
+
|
|
78
91
|
# Lazy import to avoid circular dependency
|
|
79
92
|
from ..toolkits.tools import get_tools
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
version_tools = data['tools']
|
|
94
|
+
# Handle internal tools
|
|
95
|
+
meta = data.get('meta', {})
|
|
96
|
+
if meta.get("internal_tools"):
|
|
97
|
+
# Find bucket from artifact toolkit marked with is_attachment flag
|
|
98
|
+
bucket_name = None
|
|
99
|
+
for tool in version_tools:
|
|
100
|
+
if tool.get('type') == 'artifact' and tool.get('is_attachment'):
|
|
101
|
+
bucket_name = tool.get('settings', {}).get('bucket')
|
|
102
|
+
break
|
|
103
|
+
# Fallback: use first artifact toolkit with a bucket
|
|
104
|
+
if not bucket_name:
|
|
105
|
+
for tool in version_tools:
|
|
106
|
+
if tool.get('type') == 'artifact' and tool.get('settings', {}).get('bucket'):
|
|
107
|
+
bucket_name = tool['settings']['bucket']
|
|
108
|
+
break
|
|
109
|
+
|
|
110
|
+
for internal_tool_name in meta.get("internal_tools"):
|
|
111
|
+
tool_config = {"type": "internal_tool", "name": internal_tool_name, "settings": {}}
|
|
112
|
+
if bucket_name:
|
|
113
|
+
tool_config["settings"]["bucket_name"] = bucket_name
|
|
114
|
+
version_tools.append(tool_config)
|
|
115
|
+
|
|
116
|
+
self.tools = get_tools(
|
|
117
|
+
version_tools,
|
|
118
|
+
alita_client=alita,
|
|
119
|
+
llm=self.client,
|
|
120
|
+
memory_store=self.store,
|
|
121
|
+
debug_mode=debug_mode,
|
|
122
|
+
mcp_tokens=mcp_tokens,
|
|
123
|
+
conversation_id=conversation_id,
|
|
124
|
+
ignored_mcp_servers=ignored_mcp_servers
|
|
125
|
+
)
|
|
82
126
|
if tools:
|
|
83
127
|
self.tools += tools
|
|
128
|
+
|
|
129
|
+
# Create ToolRegistry to track tool metadata and handle name collisions
|
|
130
|
+
self.tool_registry = {}
|
|
131
|
+
tool_name_counts = {} # Track how many times each base name appears
|
|
132
|
+
|
|
133
|
+
for tool in self.tools:
|
|
134
|
+
if hasattr(tool, 'name'):
|
|
135
|
+
original_name = tool.name
|
|
136
|
+
base_name = original_name
|
|
137
|
+
|
|
138
|
+
# Extract toolkit metadata from tool configuration
|
|
139
|
+
toolkit_name = ""
|
|
140
|
+
toolkit_type = ""
|
|
141
|
+
|
|
142
|
+
# Find matching tool config to extract metadata
|
|
143
|
+
for tool_config in version_tools:
|
|
144
|
+
# Try to match by toolkit_name or name field
|
|
145
|
+
config_toolkit_name = tool_config.get('toolkit_name', tool_config.get('name', ''))
|
|
146
|
+
# Simple heuristic: toolkit info should be accessible from tool config
|
|
147
|
+
# For now, use toolkit_name and type from config
|
|
148
|
+
toolkit_name = config_toolkit_name
|
|
149
|
+
toolkit_type = tool_config.get('type', '')
|
|
150
|
+
break # Use first match for now; will refine with better matching
|
|
151
|
+
|
|
152
|
+
# Handle duplicate tool names by appending numeric suffix
|
|
153
|
+
if base_name in tool_name_counts:
|
|
154
|
+
tool_name_counts[base_name] += 1
|
|
155
|
+
# Append suffix to make unique
|
|
156
|
+
new_name = f"{base_name}_{tool_name_counts[base_name]}"
|
|
157
|
+
tool.name = new_name
|
|
158
|
+
logger.info(f"Tool name collision detected: '{base_name}' -> '{new_name}'")
|
|
159
|
+
else:
|
|
160
|
+
tool_name_counts[base_name] = 0
|
|
161
|
+
new_name = base_name
|
|
162
|
+
|
|
163
|
+
# Store in registry
|
|
164
|
+
self.tool_registry[tool.name] = {
|
|
165
|
+
'toolkit_name': toolkit_name,
|
|
166
|
+
'toolkit_type': toolkit_type,
|
|
167
|
+
'original_tool_name': base_name
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
logger.info(f"ToolRegistry initialized with {len(self.tool_registry)} tools")
|
|
171
|
+
|
|
84
172
|
# Handle prompt setup
|
|
85
173
|
if app_type in ["pipeline", "predict", "react"]:
|
|
86
174
|
self.prompt = data['instructions']
|
|
@@ -92,7 +180,7 @@ class Assistant:
|
|
|
92
180
|
elif app_type == "xml":
|
|
93
181
|
messages.append(HumanMessage(XML_ADDON))
|
|
94
182
|
elif app_type in ['openai', 'dial']:
|
|
95
|
-
messages.append(
|
|
183
|
+
messages.append(MessagesPlaceholder("input"))
|
|
96
184
|
messages.append(MessagesPlaceholder("agent_scratchpad"))
|
|
97
185
|
variables = {}
|
|
98
186
|
input_variables = []
|
|
@@ -108,13 +196,18 @@ class Assistant:
|
|
|
108
196
|
messages.extend(chat_history)
|
|
109
197
|
self.prompt = Jinja2TemplatedChatMessagesTemplate(messages=messages)
|
|
110
198
|
if input_variables:
|
|
111
|
-
self.prompt.input_variables
|
|
199
|
+
if hasattr(self.prompt, 'input_variables') and self.prompt.input_variables is not None:
|
|
200
|
+
self.prompt.input_variables.extend(input_variables)
|
|
201
|
+
else:
|
|
202
|
+
self.prompt.input_variables = input_variables
|
|
112
203
|
if variables:
|
|
113
204
|
self.prompt.partial_variables = variables
|
|
114
205
|
try:
|
|
115
|
-
logger.info(
|
|
206
|
+
logger.info(
|
|
207
|
+
f"Client was created with client setting: temperature - {self.client._get_model_default_parameters}")
|
|
116
208
|
except Exception as e:
|
|
117
|
-
logger.info(
|
|
209
|
+
logger.info(
|
|
210
|
+
f"Client was created with client setting: temperature - {self.client.temperature} : {self.client.max_tokens}")
|
|
118
211
|
|
|
119
212
|
def _configure_store(self, memory_tool: dict | None) -> None:
|
|
120
213
|
"""
|
|
@@ -124,18 +217,16 @@ class Assistant:
|
|
|
124
217
|
if not memory_tool or self.store is not None:
|
|
125
218
|
return
|
|
126
219
|
from .store_manager import get_manager
|
|
127
|
-
conn_str = memory_tool.get('
|
|
220
|
+
conn_str = memory_tool['settings'].get('pgvector_configuration', {}).get('connection_string', '')
|
|
128
221
|
store = get_manager().get_store(conn_str)
|
|
129
222
|
self.store = store
|
|
130
223
|
|
|
131
224
|
def runnable(self):
|
|
132
225
|
if self.app_type == 'pipeline':
|
|
133
226
|
return self.pipeline()
|
|
134
|
-
elif self.app_type == 'openai':
|
|
135
|
-
return self.getOpenAIToolsAgentExecutor()
|
|
136
227
|
elif self.app_type == 'xml':
|
|
137
228
|
return self.getXMLAgentExecutor()
|
|
138
|
-
elif self.app_type in ['predict', 'react']:
|
|
229
|
+
elif self.app_type in ['predict', 'react', 'openai']:
|
|
139
230
|
return self.getLangGraphReactAgent()
|
|
140
231
|
else:
|
|
141
232
|
self.tools = [EchoTool()] + self.tools
|
|
@@ -144,24 +235,24 @@ class Assistant:
|
|
|
144
235
|
def _agent_executor(self, agent: Any):
|
|
145
236
|
return AgentExecutor.from_agent_and_tools(agent=agent, tools=self.tools,
|
|
146
237
|
verbose=True, handle_parsing_errors=True,
|
|
147
|
-
max_execution_time=None, return_intermediate_steps=True
|
|
238
|
+
max_execution_time=None, return_intermediate_steps=True,
|
|
239
|
+
max_iterations=self.max_iterations)
|
|
148
240
|
|
|
149
241
|
def getAgentExecutor(self):
|
|
150
242
|
# Exclude compiled graph runnables from simple tool agents
|
|
151
|
-
simple_tools = [t for t in self.tools if isinstance(t, BaseTool)]
|
|
243
|
+
simple_tools = [t for t in self.tools if isinstance(t, (BaseTool, CompiledStateGraph))]
|
|
152
244
|
agent = create_json_chat_agent(llm=self.client, tools=simple_tools, prompt=self.prompt)
|
|
153
245
|
return self._agent_executor(agent)
|
|
154
246
|
|
|
155
|
-
|
|
156
247
|
def getXMLAgentExecutor(self):
|
|
157
248
|
# Exclude compiled graph runnables from simple tool agents
|
|
158
|
-
simple_tools = [t for t in self.tools if isinstance(t, BaseTool)]
|
|
249
|
+
simple_tools = [t for t in self.tools if isinstance(t, (BaseTool, CompiledStateGraph))]
|
|
159
250
|
agent = create_xml_chat_agent(llm=self.client, tools=simple_tools, prompt=self.prompt)
|
|
160
251
|
return self._agent_executor(agent)
|
|
161
252
|
|
|
162
253
|
def getOpenAIToolsAgentExecutor(self):
|
|
163
254
|
# Exclude compiled graph runnables from simple tool agents
|
|
164
|
-
simple_tools = [t for t in self.tools if isinstance(t, BaseTool)]
|
|
255
|
+
simple_tools = [t for t in self.tools if isinstance(t, (BaseTool, CompiledStateGraph))]
|
|
165
256
|
agent = create_openai_tools_agent(llm=self.client, tools=simple_tools, prompt=self.prompt)
|
|
166
257
|
return self._agent_executor(agent)
|
|
167
258
|
|
|
@@ -171,7 +262,7 @@ class Assistant:
|
|
|
171
262
|
This creates a proper LangGraphAgentRunnable with modern tool support.
|
|
172
263
|
"""
|
|
173
264
|
# Exclude compiled graph runnables from simple tool agents
|
|
174
|
-
simple_tools = [t for t in self.tools if isinstance(t, BaseTool)]
|
|
265
|
+
simple_tools = [t for t in self.tools if isinstance(t, (BaseTool, CompiledStateGraph))]
|
|
175
266
|
|
|
176
267
|
# Set up memory/checkpointer if available
|
|
177
268
|
checkpointer = None
|
|
@@ -207,29 +298,43 @@ class Assistant:
|
|
|
207
298
|
if self.app_type == "predict" and isinstance(self.prompt, str):
|
|
208
299
|
prompt_instructions = self.prompt
|
|
209
300
|
|
|
210
|
-
# Create a unified YAML schema with conditional tool binding
|
|
211
|
-
# Build the base node configuration
|
|
212
|
-
node_config = {
|
|
213
|
-
'id': 'agent',
|
|
214
|
-
'type': 'llm',
|
|
215
|
-
'prompt': {
|
|
216
|
-
'template': prompt_instructions or "You are a helpful assistant."
|
|
217
|
-
},
|
|
218
|
-
'input': ['messages'],
|
|
219
|
-
'output': ['messages'],
|
|
220
|
-
'transition': 'END'
|
|
221
|
-
}
|
|
222
|
-
|
|
223
301
|
# Add tool binding only if tools are present
|
|
302
|
+
tool_names = []
|
|
224
303
|
if simple_tools:
|
|
225
304
|
tool_names = [tool.name for tool in simple_tools]
|
|
226
|
-
tool_names_yaml = str(tool_names).replace("'", '"') # Convert to YAML-compatible format
|
|
227
|
-
node_config['tool_names'] = tool_names_yaml
|
|
228
305
|
logger.info("Binding tools: %s", tool_names)
|
|
229
306
|
|
|
307
|
+
# take the system message from the openai prompt as a prompt instructions
|
|
308
|
+
if self.app_type == "openai" and hasattr(self.prompt, 'messages'):
|
|
309
|
+
prompt_instructions = self.__take_prompt_from_openai_messages()
|
|
310
|
+
|
|
311
|
+
user_addon = USER_ADDON.format(prompt=str(prompt_instructions)) if prompt_instructions else ""
|
|
312
|
+
plan_addon = PLAN_ADDON if 'update_plan' in tool_names else ""
|
|
313
|
+
data_analysis_addon = DATA_ANALYSIS_ADDON if 'pandas_analyze_data' in tool_names else ""
|
|
314
|
+
pyodite_addon = PYODITE_ADDON if 'pyodide_sandbox' in tool_names else ""
|
|
315
|
+
search_index_addon = SEARCH_INDEX_ADDON if 'stepback_summary_index' in tool_names else ""
|
|
316
|
+
|
|
317
|
+
# Select assistant template based on persona
|
|
318
|
+
persona_templates = {
|
|
319
|
+
"qa": QA_ASSISTANT,
|
|
320
|
+
"nerdy": NERDY_ASSISTANT,
|
|
321
|
+
"quirky": QUIRKY_ASSISTANT,
|
|
322
|
+
"cynical": CYNICAL_ASSISTANT,
|
|
323
|
+
}
|
|
324
|
+
base_assistant = persona_templates.get(self.persona, DEFAULT_ASSISTANT)
|
|
325
|
+
|
|
326
|
+
escaped_prompt = base_assistant.format(
|
|
327
|
+
users_instructions=user_addon,
|
|
328
|
+
planning_instructions=plan_addon,
|
|
329
|
+
pyodite_addon=pyodite_addon,
|
|
330
|
+
data_analysis_addon=data_analysis_addon,
|
|
331
|
+
search_index_addon=search_index_addon,
|
|
332
|
+
file_handling_instructions=FILE_HANDLING_INSTRUCTIONS
|
|
333
|
+
)
|
|
334
|
+
|
|
230
335
|
# Properly setup the prompt for YAML
|
|
231
336
|
import yaml
|
|
232
|
-
|
|
337
|
+
|
|
233
338
|
|
|
234
339
|
# Create the schema as a dictionary first, then convert to YAML
|
|
235
340
|
state_messages_config = {'type': 'list'}
|
|
@@ -247,6 +352,9 @@ class Assistant:
|
|
|
247
352
|
schema_dict = {
|
|
248
353
|
'name': 'react_agent',
|
|
249
354
|
'state': {
|
|
355
|
+
'input': {
|
|
356
|
+
'type': 'str'
|
|
357
|
+
},
|
|
250
358
|
'messages': state_messages_config
|
|
251
359
|
},
|
|
252
360
|
'nodes': [{
|
|
@@ -255,6 +363,21 @@ class Assistant:
|
|
|
255
363
|
'prompt': {
|
|
256
364
|
'template': escaped_prompt
|
|
257
365
|
},
|
|
366
|
+
'input_mapping': {
|
|
367
|
+
'system': {
|
|
368
|
+
'type': 'fixed',
|
|
369
|
+
'value': escaped_prompt
|
|
370
|
+
},
|
|
371
|
+
'task': {
|
|
372
|
+
'type': 'variable',
|
|
373
|
+
'value': 'input'
|
|
374
|
+
},
|
|
375
|
+
'chat_history': {
|
|
376
|
+
'type': 'variable',
|
|
377
|
+
'value': 'messages'
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
'step_limit': self.max_iterations,
|
|
258
381
|
'input': ['messages'],
|
|
259
382
|
'output': ['messages'],
|
|
260
383
|
'transition': 'END'
|
|
@@ -279,7 +402,9 @@ class Assistant:
|
|
|
279
402
|
memory=checkpointer,
|
|
280
403
|
store=self.store,
|
|
281
404
|
debug=False,
|
|
282
|
-
for_subgraph=False
|
|
405
|
+
for_subgraph=False,
|
|
406
|
+
alita_client=self.alita_client,
|
|
407
|
+
steps_limit=self.max_iterations
|
|
283
408
|
)
|
|
284
409
|
|
|
285
410
|
return agent
|
|
@@ -293,7 +418,9 @@ class Assistant:
|
|
|
293
418
|
#
|
|
294
419
|
agent = create_graph(
|
|
295
420
|
client=self.client, tools=self.tools,
|
|
296
|
-
yaml_schema=self.prompt, memory=memory
|
|
421
|
+
yaml_schema=self.prompt, memory=memory,
|
|
422
|
+
alita_client=self.alita_client,
|
|
423
|
+
steps_limit=self.max_iterations
|
|
297
424
|
)
|
|
298
425
|
#
|
|
299
426
|
return agent
|
|
@@ -304,3 +431,16 @@ class Assistant:
|
|
|
304
431
|
|
|
305
432
|
def predict(self, messages: list[BaseMessage]):
|
|
306
433
|
return self.client.invoke(messages)
|
|
434
|
+
|
|
435
|
+
def __take_prompt_from_openai_messages(self):
|
|
436
|
+
if self.prompt and self.prompt.messages:
|
|
437
|
+
for message in self.prompt.messages:
|
|
438
|
+
# we don't need any message placeholder from the openai agent prompt
|
|
439
|
+
if hasattr(message, 'variable_name'):
|
|
440
|
+
continue
|
|
441
|
+
# take only the content of the system message from the openai prompt
|
|
442
|
+
if isinstance(message, SystemMessage):
|
|
443
|
+
environment = Environment(undefined=DebugUndefined)
|
|
444
|
+
template = environment.from_string(message.content)
|
|
445
|
+
return template.render(self.prompt.partial_variables)
|
|
446
|
+
return None
|