alita-sdk 0.3.379__py3-none-any.whl → 0.3.627__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/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 +156 -0
- alita_sdk/cli/agent_loader.py +245 -0
- alita_sdk/cli/agent_ui.py +228 -0
- alita_sdk/cli/agents.py +3113 -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/testcases/__init__.py +94 -0
- alita_sdk/cli/testcases/data_generation.py +119 -0
- alita_sdk/cli/testcases/discovery.py +96 -0
- alita_sdk/cli/testcases/executor.py +84 -0
- alita_sdk/cli/testcases/logger.py +85 -0
- alita_sdk/cli/testcases/parser.py +172 -0
- alita_sdk/cli/testcases/prompts.py +91 -0
- alita_sdk/cli/testcases/reporting.py +125 -0
- alita_sdk/cli/testcases/setup.py +108 -0
- alita_sdk/cli/testcases/test_runner.py +282 -0
- alita_sdk/cli/testcases/utils.py +39 -0
- alita_sdk/cli/testcases/validation.py +90 -0
- alita_sdk/cli/testcases/workflow.py +196 -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 +1 -1
- alita_sdk/configurations/ado.py +141 -20
- alita_sdk/configurations/bitbucket.py +94 -2
- alita_sdk/configurations/confluence.py +130 -1
- alita_sdk/configurations/figma.py +76 -0
- alita_sdk/configurations/gitlab.py +91 -0
- alita_sdk/configurations/jira.py +103 -0
- alita_sdk/configurations/openapi.py +329 -0
- alita_sdk/configurations/qtest.py +72 -1
- alita_sdk/configurations/report_portal.py +96 -0
- alita_sdk/configurations/sharepoint.py +148 -0
- alita_sdk/configurations/testio.py +83 -0
- alita_sdk/configurations/testrail.py +88 -0
- alita_sdk/configurations/xray.py +93 -0
- alita_sdk/configurations/zephyr_enterprise.py +93 -0
- alita_sdk/configurations/zephyr_essential.py +75 -0
- alita_sdk/runtime/clients/artifact.py +3 -3
- alita_sdk/runtime/clients/client.py +388 -46
- 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 +8 -21
- alita_sdk/runtime/langchain/_constants_bkup.py +1318 -0
- alita_sdk/runtime/langchain/assistant.py +157 -39
- 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 +103 -60
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLinesLoader.py +77 -0
- alita_sdk/runtime/langchain/document_loaders/AlitaJSONLoader.py +10 -4
- alita_sdk/runtime/langchain/document_loaders/AlitaPowerPointLoader.py +226 -7
- alita_sdk/runtime/langchain/document_loaders/AlitaTextLoader.py +5 -2
- alita_sdk/runtime/langchain/document_loaders/constants.py +40 -19
- alita_sdk/runtime/langchain/langraph_agent.py +405 -84
- alita_sdk/runtime/langchain/utils.py +106 -7
- 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 +31 -0
- alita_sdk/runtime/toolkits/application.py +29 -10
- alita_sdk/runtime/toolkits/artifact.py +20 -11
- alita_sdk/runtime/toolkits/datasource.py +13 -6
- alita_sdk/runtime/toolkits/mcp.py +783 -0
- alita_sdk/runtime/toolkits/mcp_config.py +1048 -0
- alita_sdk/runtime/toolkits/planning.py +178 -0
- alita_sdk/runtime/toolkits/skill_router.py +238 -0
- alita_sdk/runtime/toolkits/subgraph.py +251 -6
- alita_sdk/runtime/toolkits/tools.py +356 -69
- alita_sdk/runtime/toolkits/vectorstore.py +11 -5
- alita_sdk/runtime/tools/__init__.py +10 -3
- alita_sdk/runtime/tools/application.py +27 -6
- alita_sdk/runtime/tools/artifact.py +511 -28
- alita_sdk/runtime/tools/data_analysis.py +183 -0
- alita_sdk/runtime/tools/function.py +67 -35
- alita_sdk/runtime/tools/graph.py +10 -4
- alita_sdk/runtime/tools/image_generation.py +148 -46
- alita_sdk/runtime/tools/llm.py +1003 -128
- 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 +8 -5
- 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 -4
- alita_sdk/runtime/tools/sandbox.py +65 -48
- alita_sdk/runtime/tools/skill_router.py +776 -0
- alita_sdk/runtime/tools/tool.py +3 -1
- alita_sdk/runtime/tools/vectorstore.py +9 -3
- alita_sdk/runtime/tools/vectorstore_base.py +70 -14
- 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/serialization.py +155 -0
- alita_sdk/runtime/utils/streamlit.py +40 -13
- alita_sdk/runtime/utils/toolkit_utils.py +30 -9
- alita_sdk/runtime/utils/utils.py +36 -0
- alita_sdk/tools/__init__.py +134 -35
- alita_sdk/tools/ado/repos/__init__.py +51 -32
- alita_sdk/tools/ado/repos/repos_wrapper.py +148 -89
- alita_sdk/tools/ado/test_plan/__init__.py +25 -9
- alita_sdk/tools/ado/test_plan/test_plan_wrapper.py +23 -1
- alita_sdk/tools/ado/utils.py +1 -18
- alita_sdk/tools/ado/wiki/__init__.py +25 -12
- alita_sdk/tools/ado/wiki/ado_wrapper.py +291 -22
- alita_sdk/tools/ado/work_item/__init__.py +26 -13
- alita_sdk/tools/ado/work_item/ado_wrapper.py +73 -11
- alita_sdk/tools/advanced_jira_mining/__init__.py +11 -8
- alita_sdk/tools/aws/delta_lake/__init__.py +13 -9
- alita_sdk/tools/aws/delta_lake/tool.py +5 -1
- alita_sdk/tools/azure_ai/search/__init__.py +11 -8
- alita_sdk/tools/azure_ai/search/api_wrapper.py +1 -1
- alita_sdk/tools/base/tool.py +5 -1
- alita_sdk/tools/base_indexer_toolkit.py +271 -84
- alita_sdk/tools/bitbucket/__init__.py +17 -11
- alita_sdk/tools/bitbucket/api_wrapper.py +59 -11
- alita_sdk/tools/bitbucket/cloud_api_wrapper.py +49 -35
- alita_sdk/tools/browser/__init__.py +5 -4
- alita_sdk/tools/carrier/__init__.py +5 -6
- alita_sdk/tools/carrier/backend_reports_tool.py +6 -6
- alita_sdk/tools/carrier/run_ui_test_tool.py +6 -6
- alita_sdk/tools/carrier/ui_reports_tool.py +5 -5
- alita_sdk/tools/chunkers/__init__.py +3 -1
- alita_sdk/tools/chunkers/code/treesitter/treesitter.py +37 -13
- alita_sdk/tools/chunkers/sematic/json_chunker.py +1 -0
- 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 +10 -7
- alita_sdk/tools/cloud/azure/__init__.py +10 -7
- alita_sdk/tools/cloud/gcp/__init__.py +10 -7
- alita_sdk/tools/cloud/k8s/__init__.py +10 -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 +11 -8
- alita_sdk/tools/code_indexer_toolkit.py +82 -22
- alita_sdk/tools/confluence/__init__.py +22 -16
- alita_sdk/tools/confluence/api_wrapper.py +107 -30
- 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 +493 -30
- alita_sdk/tools/figma/__init__.py +58 -11
- alita_sdk/tools/figma/api_wrapper.py +1235 -143
- alita_sdk/tools/figma/figma_client.py +73 -0
- alita_sdk/tools/figma/toon_tools.py +2748 -0
- alita_sdk/tools/github/__init__.py +14 -15
- alita_sdk/tools/github/github_client.py +224 -100
- alita_sdk/tools/github/graphql_client_wrapper.py +119 -33
- alita_sdk/tools/github/schemas.py +14 -5
- alita_sdk/tools/github/tool.py +5 -1
- alita_sdk/tools/github/tool_prompts.py +9 -22
- alita_sdk/tools/gitlab/__init__.py +16 -11
- alita_sdk/tools/gitlab/api_wrapper.py +218 -48
- alita_sdk/tools/gitlab_org/__init__.py +10 -9
- alita_sdk/tools/gitlab_org/api_wrapper.py +63 -64
- alita_sdk/tools/google/bigquery/__init__.py +13 -12
- alita_sdk/tools/google/bigquery/tool.py +5 -1
- alita_sdk/tools/google_places/__init__.py +11 -8
- alita_sdk/tools/google_places/api_wrapper.py +1 -1
- alita_sdk/tools/jira/__init__.py +17 -10
- alita_sdk/tools/jira/api_wrapper.py +92 -41
- 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 +12 -4
- alita_sdk/tools/non_code_indexer_toolkit.py +1 -0
- alita_sdk/tools/ocr/__init__.py +11 -8
- alita_sdk/tools/openapi/__init__.py +491 -106
- alita_sdk/tools/openapi/api_wrapper.py +1368 -0
- alita_sdk/tools/openapi/tool.py +20 -0
- alita_sdk/tools/pandas/__init__.py +20 -12
- alita_sdk/tools/pandas/api_wrapper.py +38 -25
- alita_sdk/tools/pandas/dataframe/generator/base.py +3 -1
- alita_sdk/tools/postman/__init__.py +10 -9
- alita_sdk/tools/pptx/__init__.py +11 -10
- alita_sdk/tools/pptx/pptx_wrapper.py +1 -1
- alita_sdk/tools/qtest/__init__.py +31 -11
- alita_sdk/tools/qtest/api_wrapper.py +2135 -86
- alita_sdk/tools/rally/__init__.py +10 -9
- alita_sdk/tools/rally/api_wrapper.py +1 -1
- alita_sdk/tools/report_portal/__init__.py +12 -8
- alita_sdk/tools/salesforce/__init__.py +10 -8
- alita_sdk/tools/servicenow/__init__.py +17 -15
- alita_sdk/tools/servicenow/api_wrapper.py +1 -1
- alita_sdk/tools/sharepoint/__init__.py +10 -7
- alita_sdk/tools/sharepoint/api_wrapper.py +129 -38
- alita_sdk/tools/sharepoint/authorization_helper.py +191 -1
- alita_sdk/tools/sharepoint/utils.py +8 -2
- alita_sdk/tools/slack/__init__.py +10 -7
- alita_sdk/tools/slack/api_wrapper.py +2 -2
- alita_sdk/tools/sql/__init__.py +12 -9
- alita_sdk/tools/testio/__init__.py +10 -7
- alita_sdk/tools/testrail/__init__.py +11 -10
- alita_sdk/tools/testrail/api_wrapper.py +1 -1
- alita_sdk/tools/utils/__init__.py +9 -4
- alita_sdk/tools/utils/content_parser.py +103 -18
- alita_sdk/tools/utils/text_operations.py +410 -0
- alita_sdk/tools/utils/tool_prompts.py +79 -0
- alita_sdk/tools/vector_adapters/VectorStoreAdapter.py +30 -13
- alita_sdk/tools/xray/__init__.py +13 -9
- alita_sdk/tools/yagmail/__init__.py +9 -3
- alita_sdk/tools/zephyr/__init__.py +10 -7
- alita_sdk/tools/zephyr_enterprise/__init__.py +11 -7
- alita_sdk/tools/zephyr_essential/__init__.py +10 -7
- alita_sdk/tools/zephyr_essential/api_wrapper.py +30 -13
- alita_sdk/tools/zephyr_essential/client.py +2 -2
- alita_sdk/tools/zephyr_scale/__init__.py +11 -8
- alita_sdk/tools/zephyr_scale/api_wrapper.py +2 -2
- alita_sdk/tools/zephyr_squad/__init__.py +10 -7
- {alita_sdk-0.3.379.dist-info → alita_sdk-0.3.627.dist-info}/METADATA +154 -8
- alita_sdk-0.3.627.dist-info/RECORD +468 -0
- alita_sdk-0.3.627.dist-info/entry_points.txt +2 -0
- alita_sdk-0.3.379.dist-info/RECORD +0 -360
- {alita_sdk-0.3.379.dist-info → alita_sdk-0.3.627.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.379.dist-info → alita_sdk-0.3.627.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.379.dist-info → alita_sdk-0.3.627.dist-info}/top_level.txt +0 -0
|
@@ -13,10 +13,14 @@ from langchain_core.messages import (
|
|
|
13
13
|
BaseMessage, SystemMessage, HumanMessage
|
|
14
14
|
)
|
|
15
15
|
from langchain_core.prompts import MessagesPlaceholder
|
|
16
|
-
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)
|
|
17
20
|
from .chat_message_template import Jinja2TemplatedChatMessagesTemplate
|
|
18
21
|
from ..tools.echo import EchoTool
|
|
19
22
|
from langchain_core.tools import BaseTool, ToolException
|
|
23
|
+
from jinja2 import Environment, DebugUndefined
|
|
20
24
|
|
|
21
25
|
logger = logging.getLogger(__name__)
|
|
22
26
|
|
|
@@ -29,12 +33,20 @@ class Assistant:
|
|
|
29
33
|
app_type: str = "openai",
|
|
30
34
|
tools: Optional[list] = [],
|
|
31
35
|
memory: Optional[Any] = None,
|
|
32
|
-
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",
|
|
42
|
+
is_subgraph: bool = False):
|
|
33
43
|
|
|
34
44
|
self.app_type = app_type
|
|
35
45
|
self.memory = memory
|
|
36
46
|
self.store = store
|
|
47
|
+
self.persona = persona
|
|
37
48
|
self.max_iterations = data.get('meta', {}).get('step_limit', 25)
|
|
49
|
+
self.is_subgraph = is_subgraph # Store is_subgraph flag
|
|
38
50
|
|
|
39
51
|
logger.debug("Data for agent creation: %s", data)
|
|
40
52
|
logger.info("App type: %s", app_type)
|
|
@@ -84,12 +96,81 @@ class Assistant:
|
|
|
84
96
|
# Handle internal tools
|
|
85
97
|
meta = data.get('meta', {})
|
|
86
98
|
if meta.get("internal_tools"):
|
|
99
|
+
# Find bucket from artifact toolkit marked with is_attachment flag
|
|
100
|
+
bucket_name = None
|
|
101
|
+
for tool in version_tools:
|
|
102
|
+
if tool.get('type') == 'artifact' and tool.get('is_attachment'):
|
|
103
|
+
bucket_name = tool.get('settings', {}).get('bucket')
|
|
104
|
+
break
|
|
105
|
+
# Fallback: use first artifact toolkit with a bucket
|
|
106
|
+
if not bucket_name:
|
|
107
|
+
for tool in version_tools:
|
|
108
|
+
if tool.get('type') == 'artifact' and tool.get('settings', {}).get('bucket'):
|
|
109
|
+
bucket_name = tool['settings']['bucket']
|
|
110
|
+
break
|
|
111
|
+
|
|
87
112
|
for internal_tool_name in meta.get("internal_tools"):
|
|
88
|
-
|
|
113
|
+
tool_config = {"type": "internal_tool", "name": internal_tool_name, "settings": {}}
|
|
114
|
+
if bucket_name:
|
|
115
|
+
tool_config["settings"]["bucket_name"] = bucket_name
|
|
116
|
+
version_tools.append(tool_config)
|
|
89
117
|
|
|
90
|
-
self.tools = get_tools(
|
|
118
|
+
self.tools = get_tools(
|
|
119
|
+
version_tools,
|
|
120
|
+
alita_client=alita,
|
|
121
|
+
llm=self.client,
|
|
122
|
+
memory_store=self.store,
|
|
123
|
+
debug_mode=debug_mode,
|
|
124
|
+
mcp_tokens=mcp_tokens,
|
|
125
|
+
conversation_id=conversation_id,
|
|
126
|
+
ignored_mcp_servers=ignored_mcp_servers
|
|
127
|
+
)
|
|
91
128
|
if tools:
|
|
92
129
|
self.tools += tools
|
|
130
|
+
|
|
131
|
+
# Create ToolRegistry to track tool metadata and handle name collisions
|
|
132
|
+
self.tool_registry = {}
|
|
133
|
+
tool_name_counts = {} # Track how many times each base name appears
|
|
134
|
+
|
|
135
|
+
for tool in self.tools:
|
|
136
|
+
if hasattr(tool, 'name'):
|
|
137
|
+
original_name = tool.name
|
|
138
|
+
base_name = original_name
|
|
139
|
+
|
|
140
|
+
# Extract toolkit metadata from tool configuration
|
|
141
|
+
toolkit_name = ""
|
|
142
|
+
toolkit_type = ""
|
|
143
|
+
|
|
144
|
+
# Find matching tool config to extract metadata
|
|
145
|
+
for tool_config in version_tools:
|
|
146
|
+
# Try to match by toolkit_name or name field
|
|
147
|
+
config_toolkit_name = tool_config.get('toolkit_name', tool_config.get('name', ''))
|
|
148
|
+
# Simple heuristic: toolkit info should be accessible from tool config
|
|
149
|
+
# For now, use toolkit_name and type from config
|
|
150
|
+
toolkit_name = config_toolkit_name
|
|
151
|
+
toolkit_type = tool_config.get('type', '')
|
|
152
|
+
break # Use first match for now; will refine with better matching
|
|
153
|
+
|
|
154
|
+
# Handle duplicate tool names by appending numeric suffix
|
|
155
|
+
if base_name in tool_name_counts:
|
|
156
|
+
tool_name_counts[base_name] += 1
|
|
157
|
+
# Append suffix to make unique
|
|
158
|
+
new_name = f"{base_name}_{tool_name_counts[base_name]}"
|
|
159
|
+
tool.name = new_name
|
|
160
|
+
logger.info(f"Tool name collision detected: '{base_name}' -> '{new_name}'")
|
|
161
|
+
else:
|
|
162
|
+
tool_name_counts[base_name] = 0
|
|
163
|
+
new_name = base_name
|
|
164
|
+
|
|
165
|
+
# Store in registry
|
|
166
|
+
self.tool_registry[tool.name] = {
|
|
167
|
+
'toolkit_name': toolkit_name,
|
|
168
|
+
'toolkit_type': toolkit_type,
|
|
169
|
+
'original_tool_name': base_name
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
logger.info(f"ToolRegistry initialized with {len(self.tool_registry)} tools")
|
|
173
|
+
|
|
93
174
|
# Handle prompt setup
|
|
94
175
|
if app_type in ["pipeline", "predict", "react"]:
|
|
95
176
|
self.prompt = data['instructions']
|
|
@@ -184,17 +265,6 @@ class Assistant:
|
|
|
184
265
|
"""
|
|
185
266
|
# Exclude compiled graph runnables from simple tool agents
|
|
186
267
|
simple_tools = [t for t in self.tools if isinstance(t, (BaseTool, CompiledStateGraph))]
|
|
187
|
-
# Add image generation tool if model is configured
|
|
188
|
-
if self.alita_client.model_image_generation is not None:
|
|
189
|
-
try:
|
|
190
|
-
from ..tools.image_generation import (
|
|
191
|
-
create_image_generation_tool
|
|
192
|
-
)
|
|
193
|
-
image_tool = create_image_generation_tool(self.alita_client)
|
|
194
|
-
simple_tools.append(image_tool)
|
|
195
|
-
logger.info("Added ImageGenerationTool to react agent")
|
|
196
|
-
except Exception as e:
|
|
197
|
-
logger.error(f"Error adding ImageGenerationTool: {e}")
|
|
198
268
|
|
|
199
269
|
# Set up memory/checkpointer if available
|
|
200
270
|
checkpointer = None
|
|
@@ -227,36 +297,61 @@ class Assistant:
|
|
|
227
297
|
chat_history_messages.append(message)
|
|
228
298
|
|
|
229
299
|
# Only use prompt_instructions if explicitly specified (for predict app_type)
|
|
230
|
-
if self.app_type
|
|
300
|
+
if self.app_type in ["predict", "react"] and isinstance(self.prompt, str):
|
|
231
301
|
prompt_instructions = self.prompt
|
|
232
|
-
|
|
233
|
-
# take the system message from the openai prompt as a prompt instructions
|
|
234
|
-
if self.app_type == "openai" and hasattr(self.prompt, 'messages'):
|
|
235
|
-
prompt_instructions = self.__take_prompt_from_openai_messages()
|
|
236
|
-
|
|
237
|
-
# Create a unified YAML schema with conditional tool binding
|
|
238
|
-
# Build the base node configuration
|
|
239
|
-
node_config = {
|
|
240
|
-
'id': 'agent',
|
|
241
|
-
'type': 'llm',
|
|
242
|
-
'prompt': {
|
|
243
|
-
'template': prompt_instructions or "You are a helpful assistant."
|
|
244
|
-
},
|
|
245
|
-
'input': ['messages'],
|
|
246
|
-
'output': ['messages'],
|
|
247
|
-
'transition': 'END'
|
|
248
|
-
}
|
|
249
302
|
|
|
250
303
|
# Add tool binding only if tools are present
|
|
304
|
+
tool_names = []
|
|
251
305
|
if simple_tools:
|
|
252
306
|
tool_names = [tool.name for tool in simple_tools]
|
|
253
|
-
tool_names_yaml = str(tool_names).replace("'", '"') # Convert to YAML-compatible format
|
|
254
|
-
node_config['tool_names'] = tool_names_yaml
|
|
255
307
|
logger.info("Binding tools: %s", tool_names)
|
|
256
308
|
|
|
309
|
+
# take the system message from the openai prompt as a prompt instructions
|
|
310
|
+
if self.app_type == "openai" and hasattr(self.prompt, 'messages'):
|
|
311
|
+
prompt_instructions = self.__take_prompt_from_openai_messages()
|
|
312
|
+
|
|
313
|
+
user_addon = USER_ADDON.format(prompt=str(prompt_instructions)) if prompt_instructions else ""
|
|
314
|
+
plan_addon = PLAN_ADDON if 'update_plan' in tool_names else ""
|
|
315
|
+
data_analysis_addon = DATA_ANALYSIS_ADDON if 'pandas_analyze_data' in tool_names else ""
|
|
316
|
+
pyodite_addon = PYODITE_ADDON if 'pyodide_sandbox' in tool_names else ""
|
|
317
|
+
search_index_addon = SEARCH_INDEX_ADDON if 'stepback_summary_index' in tool_names else ""
|
|
318
|
+
|
|
319
|
+
# Select assistant template based on persona
|
|
320
|
+
persona_templates = {
|
|
321
|
+
"qa": QA_ASSISTANT,
|
|
322
|
+
"nerdy": NERDY_ASSISTANT,
|
|
323
|
+
"quirky": QUIRKY_ASSISTANT,
|
|
324
|
+
"cynical": CYNICAL_ASSISTANT,
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
# For predict agents with their own instructions, use those directly
|
|
328
|
+
# instead of wrapping in DEFAULT_ASSISTANT
|
|
329
|
+
if self.app_type == "openai" and prompt_instructions:
|
|
330
|
+
# Use agent's own instructions as the base system prompt
|
|
331
|
+
# Append addons only when their corresponding tools are present
|
|
332
|
+
addons = "\n\n---\n\n".join(filter(None, [
|
|
333
|
+
plan_addon,
|
|
334
|
+
search_index_addon,
|
|
335
|
+
FILE_HANDLING_INSTRUCTIONS if simple_tools else "",
|
|
336
|
+
pyodite_addon,
|
|
337
|
+
data_analysis_addon
|
|
338
|
+
]))
|
|
339
|
+
escaped_prompt = f"{prompt_instructions}\n\n---\n\n{addons}" if addons else str(prompt_instructions)
|
|
340
|
+
logger.info("Using agent's own instructions directly (app_type=predict)")
|
|
341
|
+
else:
|
|
342
|
+
base_assistant = persona_templates.get(self.persona, DEFAULT_ASSISTANT)
|
|
343
|
+
escaped_prompt = base_assistant.format(
|
|
344
|
+
users_instructions=user_addon,
|
|
345
|
+
planning_instructions=plan_addon,
|
|
346
|
+
pyodite_addon=pyodite_addon,
|
|
347
|
+
data_analysis_addon=data_analysis_addon,
|
|
348
|
+
search_index_addon=search_index_addon,
|
|
349
|
+
file_handling_instructions=FILE_HANDLING_INSTRUCTIONS
|
|
350
|
+
)
|
|
351
|
+
|
|
257
352
|
# Properly setup the prompt for YAML
|
|
258
353
|
import yaml
|
|
259
|
-
|
|
354
|
+
|
|
260
355
|
|
|
261
356
|
# Create the schema as a dictionary first, then convert to YAML
|
|
262
357
|
state_messages_config = {'type': 'list'}
|
|
@@ -274,6 +369,9 @@ class Assistant:
|
|
|
274
369
|
schema_dict = {
|
|
275
370
|
'name': 'react_agent',
|
|
276
371
|
'state': {
|
|
372
|
+
'input': {
|
|
373
|
+
'type': 'str'
|
|
374
|
+
},
|
|
277
375
|
'messages': state_messages_config
|
|
278
376
|
},
|
|
279
377
|
'nodes': [{
|
|
@@ -282,6 +380,21 @@ class Assistant:
|
|
|
282
380
|
'prompt': {
|
|
283
381
|
'template': escaped_prompt
|
|
284
382
|
},
|
|
383
|
+
'input_mapping': {
|
|
384
|
+
'system': {
|
|
385
|
+
'type': 'fixed',
|
|
386
|
+
'value': escaped_prompt
|
|
387
|
+
},
|
|
388
|
+
'task': {
|
|
389
|
+
'type': 'variable',
|
|
390
|
+
'value': 'input'
|
|
391
|
+
},
|
|
392
|
+
'chat_history': {
|
|
393
|
+
'type': 'variable',
|
|
394
|
+
'value': 'messages'
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
'step_limit': self.max_iterations,
|
|
285
398
|
'input': ['messages'],
|
|
286
399
|
'output': ['messages'],
|
|
287
400
|
'transition': 'END'
|
|
@@ -307,7 +420,8 @@ class Assistant:
|
|
|
307
420
|
store=self.store,
|
|
308
421
|
debug=False,
|
|
309
422
|
for_subgraph=False,
|
|
310
|
-
alita_client=self.alita_client
|
|
423
|
+
alita_client=self.alita_client,
|
|
424
|
+
steps_limit=self.max_iterations
|
|
311
425
|
)
|
|
312
426
|
|
|
313
427
|
return agent
|
|
@@ -322,7 +436,9 @@ class Assistant:
|
|
|
322
436
|
agent = create_graph(
|
|
323
437
|
client=self.client, tools=self.tools,
|
|
324
438
|
yaml_schema=self.prompt, memory=memory,
|
|
325
|
-
alita_client=self.alita_client
|
|
439
|
+
alita_client=self.alita_client,
|
|
440
|
+
steps_limit=self.max_iterations,
|
|
441
|
+
for_subgraph=self.is_subgraph # Pass for_subgraph flag to filter PrinterNodes
|
|
326
442
|
)
|
|
327
443
|
#
|
|
328
444
|
return agent
|
|
@@ -342,5 +458,7 @@ class Assistant:
|
|
|
342
458
|
continue
|
|
343
459
|
# take only the content of the system message from the openai prompt
|
|
344
460
|
if isinstance(message, SystemMessage):
|
|
345
|
-
|
|
461
|
+
environment = Environment(undefined=DebugUndefined)
|
|
462
|
+
template = environment.from_string(message.content)
|
|
463
|
+
return template.render(self.prompt.partial_variables)
|
|
346
464
|
return None
|