alita-sdk 0.3.462__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/agent/__init__.py +5 -0
- alita_sdk/cli/agent/default.py +258 -0
- alita_sdk/cli/agent_executor.py +15 -3
- alita_sdk/cli/agent_loader.py +56 -8
- alita_sdk/cli/agent_ui.py +93 -31
- alita_sdk/cli/agents.py +2274 -230
- alita_sdk/cli/callbacks.py +96 -25
- alita_sdk/cli/cli.py +10 -1
- alita_sdk/cli/config.py +162 -9
- 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/input_handler.py +419 -0
- alita_sdk/cli/inventory.py +1073 -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 +14 -17
- alita_sdk/cli/toolkit_loader.py +35 -5
- alita_sdk/cli/tools/__init__.py +36 -2
- alita_sdk/cli/tools/approval.py +224 -0
- alita_sdk/cli/tools/filesystem.py +910 -64
- 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 +0 -3
- alita_sdk/configurations/confluence.py +76 -42
- alita_sdk/configurations/figma.py +76 -0
- alita_sdk/configurations/gitlab.py +17 -5
- 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/runtime/clients/artifact.py +3 -3
- alita_sdk/runtime/clients/client.py +353 -48
- alita_sdk/runtime/clients/sandbox_client.py +0 -21
- alita_sdk/runtime/langchain/_constants_bkup.py +1318 -0
- alita_sdk/runtime/langchain/assistant.py +123 -26
- alita_sdk/runtime/langchain/constants.py +642 -1
- 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 +6 -3
- 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 +12 -7
- alita_sdk/runtime/langchain/langraph_agent.py +279 -73
- alita_sdk/runtime/langchain/utils.py +82 -15
- alita_sdk/runtime/llms/preloaded.py +2 -6
- 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 +7 -0
- alita_sdk/runtime/toolkits/application.py +21 -9
- alita_sdk/runtime/toolkits/artifact.py +15 -5
- alita_sdk/runtime/toolkits/datasource.py +13 -6
- alita_sdk/runtime/toolkits/mcp.py +139 -251
- 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 +238 -32
- alita_sdk/runtime/toolkits/vectorstore.py +11 -5
- alita_sdk/runtime/tools/__init__.py +3 -1
- alita_sdk/runtime/tools/application.py +20 -6
- alita_sdk/runtime/tools/artifact.py +511 -28
- alita_sdk/runtime/tools/data_analysis.py +183 -0
- alita_sdk/runtime/tools/function.py +43 -15
- alita_sdk/runtime/tools/image_generation.py +50 -44
- alita_sdk/runtime/tools/llm.py +852 -67
- alita_sdk/runtime/tools/loop.py +3 -1
- alita_sdk/runtime/tools/loop_output.py +3 -1
- alita_sdk/runtime/tools/mcp_remote_tool.py +25 -10
- alita_sdk/runtime/tools/mcp_server_tool.py +7 -6
- 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 +9 -6
- alita_sdk/runtime/tools/skill_router.py +776 -0
- alita_sdk/runtime/tools/tool.py +3 -1
- alita_sdk/runtime/tools/vectorstore.py +7 -2
- alita_sdk/runtime/tools/vectorstore_base.py +51 -11
- 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 +202 -5
- alita_sdk/runtime/utils/mcp_sse_client.py +36 -7
- alita_sdk/runtime/utils/mcp_tools_discovery.py +124 -0
- alita_sdk/runtime/utils/serialization.py +155 -0
- alita_sdk/runtime/utils/streamlit.py +6 -10
- alita_sdk/runtime/utils/toolkit_utils.py +16 -5
- alita_sdk/runtime/utils/utils.py +36 -0
- alita_sdk/tools/__init__.py +113 -29
- alita_sdk/tools/ado/repos/__init__.py +51 -33
- 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 -8
- alita_sdk/tools/ado/wiki/ado_wrapper.py +291 -22
- alita_sdk/tools/ado/work_item/__init__.py +26 -9
- alita_sdk/tools/ado/work_item/ado_wrapper.py +56 -3
- 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 +170 -45
- alita_sdk/tools/bitbucket/__init__.py +17 -12
- 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/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 +10 -7
- alita_sdk/tools/code_indexer_toolkit.py +73 -23
- alita_sdk/tools/confluence/__init__.py +21 -15
- alita_sdk/tools/confluence/api_wrapper.py +78 -23
- alita_sdk/tools/confluence/loader.py +4 -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 +13 -14
- 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 +15 -11
- alita_sdk/tools/gitlab/api_wrapper.py +207 -41
- alita_sdk/tools/gitlab_org/__init__.py +10 -8
- 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 +10 -8
- alita_sdk/tools/google_places/api_wrapper.py +1 -1
- alita_sdk/tools/jira/__init__.py +17 -11
- alita_sdk/tools/jira/api_wrapper.py +91 -40
- 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 +11 -3
- alita_sdk/tools/non_code_indexer_toolkit.py +1 -0
- alita_sdk/tools/ocr/__init__.py +11 -8
- alita_sdk/tools/openapi/__init__.py +490 -114
- 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 +11 -11
- alita_sdk/tools/pptx/__init__.py +10 -9
- alita_sdk/tools/pptx/pptx_wrapper.py +1 -1
- alita_sdk/tools/qtest/__init__.py +30 -10
- alita_sdk/tools/qtest/api_wrapper.py +430 -13
- alita_sdk/tools/rally/__init__.py +10 -8
- alita_sdk/tools/rally/api_wrapper.py +1 -1
- alita_sdk/tools/report_portal/__init__.py +12 -9
- alita_sdk/tools/salesforce/__init__.py +10 -9
- alita_sdk/tools/servicenow/__init__.py +17 -14
- alita_sdk/tools/servicenow/api_wrapper.py +1 -1
- alita_sdk/tools/sharepoint/__init__.py +10 -8
- alita_sdk/tools/sharepoint/api_wrapper.py +4 -4
- alita_sdk/tools/slack/__init__.py +10 -8
- alita_sdk/tools/slack/api_wrapper.py +2 -2
- alita_sdk/tools/sql/__init__.py +11 -9
- alita_sdk/tools/testio/__init__.py +10 -8
- alita_sdk/tools/testrail/__init__.py +11 -8
- alita_sdk/tools/testrail/api_wrapper.py +1 -1
- alita_sdk/tools/utils/__init__.py +9 -4
- alita_sdk/tools/utils/content_parser.py +77 -3
- 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 +17 -13
- alita_sdk/tools/xray/__init__.py +12 -9
- alita_sdk/tools/yagmail/__init__.py +9 -3
- alita_sdk/tools/zephyr/__init__.py +9 -7
- alita_sdk/tools/zephyr_enterprise/__init__.py +11 -8
- alita_sdk/tools/zephyr_essential/__init__.py +10 -8
- 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 -9
- alita_sdk/tools/zephyr_scale/api_wrapper.py +2 -2
- alita_sdk/tools/zephyr_squad/__init__.py +10 -8
- {alita_sdk-0.3.462.dist-info → alita_sdk-0.3.627.dist-info}/METADATA +147 -7
- 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.462.dist-info/RECORD +0 -384
- alita_sdk-0.3.462.dist-info/entry_points.txt +0 -2
- {alita_sdk-0.3.462.dist-info → alita_sdk-0.3.627.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.462.dist-info → alita_sdk-0.3.627.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.462.dist-info → alita_sdk-0.3.627.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,10 @@ 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
|
|
@@ -32,12 +35,18 @@ class Assistant:
|
|
|
32
35
|
memory: Optional[Any] = None,
|
|
33
36
|
store: Optional[BaseStore] = None,
|
|
34
37
|
debug_mode: Optional[bool] = False,
|
|
35
|
-
mcp_tokens: Optional[dict] = None
|
|
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):
|
|
36
43
|
|
|
37
44
|
self.app_type = app_type
|
|
38
45
|
self.memory = memory
|
|
39
46
|
self.store = store
|
|
47
|
+
self.persona = persona
|
|
40
48
|
self.max_iterations = data.get('meta', {}).get('step_limit', 25)
|
|
49
|
+
self.is_subgraph = is_subgraph # Store is_subgraph flag
|
|
41
50
|
|
|
42
51
|
logger.debug("Data for agent creation: %s", data)
|
|
43
52
|
logger.info("App type: %s", app_type)
|
|
@@ -87,8 +96,24 @@ class Assistant:
|
|
|
87
96
|
# Handle internal tools
|
|
88
97
|
meta = data.get('meta', {})
|
|
89
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
|
+
|
|
90
112
|
for internal_tool_name in meta.get("internal_tools"):
|
|
91
|
-
|
|
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)
|
|
92
117
|
|
|
93
118
|
self.tools = get_tools(
|
|
94
119
|
version_tools,
|
|
@@ -96,10 +121,56 @@ class Assistant:
|
|
|
96
121
|
llm=self.client,
|
|
97
122
|
memory_store=self.store,
|
|
98
123
|
debug_mode=debug_mode,
|
|
99
|
-
mcp_tokens=mcp_tokens
|
|
124
|
+
mcp_tokens=mcp_tokens,
|
|
125
|
+
conversation_id=conversation_id,
|
|
126
|
+
ignored_mcp_servers=ignored_mcp_servers
|
|
100
127
|
)
|
|
101
128
|
if tools:
|
|
102
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
|
+
|
|
103
174
|
# Handle prompt setup
|
|
104
175
|
if app_type in ["pipeline", "predict", "react"]:
|
|
105
176
|
self.prompt = data['instructions']
|
|
@@ -226,36 +297,61 @@ class Assistant:
|
|
|
226
297
|
chat_history_messages.append(message)
|
|
227
298
|
|
|
228
299
|
# Only use prompt_instructions if explicitly specified (for predict app_type)
|
|
229
|
-
if self.app_type
|
|
300
|
+
if self.app_type in ["predict", "react"] and isinstance(self.prompt, str):
|
|
230
301
|
prompt_instructions = self.prompt
|
|
231
|
-
|
|
232
|
-
# take the system message from the openai prompt as a prompt instructions
|
|
233
|
-
if self.app_type == "openai" and hasattr(self.prompt, 'messages'):
|
|
234
|
-
prompt_instructions = self.__take_prompt_from_openai_messages()
|
|
235
|
-
|
|
236
|
-
# Create a unified YAML schema with conditional tool binding
|
|
237
|
-
# Build the base node configuration
|
|
238
|
-
node_config = {
|
|
239
|
-
'id': 'agent',
|
|
240
|
-
'type': 'llm',
|
|
241
|
-
'prompt': {
|
|
242
|
-
'template': prompt_instructions or "You are a helpful assistant."
|
|
243
|
-
},
|
|
244
|
-
'input': ['messages'],
|
|
245
|
-
'output': ['messages'],
|
|
246
|
-
'transition': 'END'
|
|
247
|
-
}
|
|
248
302
|
|
|
249
303
|
# Add tool binding only if tools are present
|
|
304
|
+
tool_names = []
|
|
250
305
|
if simple_tools:
|
|
251
306
|
tool_names = [tool.name for tool in simple_tools]
|
|
252
|
-
tool_names_yaml = str(tool_names).replace("'", '"') # Convert to YAML-compatible format
|
|
253
|
-
node_config['tool_names'] = tool_names_yaml
|
|
254
307
|
logger.info("Binding tools: %s", tool_names)
|
|
255
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
|
+
|
|
256
352
|
# Properly setup the prompt for YAML
|
|
257
353
|
import yaml
|
|
258
|
-
|
|
354
|
+
|
|
259
355
|
|
|
260
356
|
# Create the schema as a dictionary first, then convert to YAML
|
|
261
357
|
state_messages_config = {'type': 'list'}
|
|
@@ -341,7 +437,8 @@ class Assistant:
|
|
|
341
437
|
client=self.client, tools=self.tools,
|
|
342
438
|
yaml_schema=self.prompt, memory=memory,
|
|
343
439
|
alita_client=self.alita_client,
|
|
344
|
-
steps_limit=self.max_iterations
|
|
440
|
+
steps_limit=self.max_iterations,
|
|
441
|
+
for_subgraph=self.is_subgraph # Pass for_subgraph flag to filter PrinterNodes
|
|
345
442
|
)
|
|
346
443
|
#
|
|
347
444
|
return agent
|