solace-agent-mesh 0.1.3__py3-none-any.whl → 0.2.0__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 solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agents/global/actions/plantuml_diagram.py +9 -2
- solace_agent_mesh/agents/global/actions/plotly_graph.py +38 -40
- solace_agent_mesh/agents/web_request/actions/do_web_request.py +34 -33
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add/gateway.py +162 -9
- solace_agent_mesh/cli/commands/build.py +0 -1
- solace_agent_mesh/cli/commands/init/create_other_project_files_step.py +52 -1
- solace_agent_mesh/cli/commands/plugin/build.py +11 -2
- solace_agent_mesh/cli/config.py +4 -0
- solace_agent_mesh/cli/utils.py +7 -2
- solace_agent_mesh/common/constants.py +10 -0
- solace_agent_mesh/common/utils.py +16 -11
- solace_agent_mesh/configs/service_embedding.yaml +1 -1
- solace_agent_mesh/configs/service_llm.yaml +1 -1
- solace_agent_mesh/gateway/components/gateway_base.py +7 -1
- solace_agent_mesh/gateway/components/gateway_input.py +8 -5
- solace_agent_mesh/gateway/components/gateway_output.py +12 -3
- solace_agent_mesh/orchestrator/components/orchestrator_stimulus_processor_component.py +23 -5
- solace_agent_mesh/orchestrator/orchestrator_prompt.py +155 -35
- solace_agent_mesh/services/file_service/file_service.py +5 -0
- solace_agent_mesh/services/file_service/file_service_constants.py +1 -1
- solace_agent_mesh/services/file_service/file_transformations.py +11 -1
- solace_agent_mesh/services/file_service/file_utils.py +2 -0
- solace_agent_mesh/services/history_service/history_providers/base_history_provider.py +21 -46
- solace_agent_mesh/services/history_service/history_providers/file_history_provider.py +74 -0
- solace_agent_mesh/services/history_service/history_providers/index.py +40 -0
- solace_agent_mesh/services/history_service/history_providers/memory_history_provider.py +19 -156
- solace_agent_mesh/services/history_service/history_providers/mongodb_history_provider.py +66 -0
- solace_agent_mesh/services/history_service/history_providers/redis_history_provider.py +40 -140
- solace_agent_mesh/services/history_service/history_providers/sql_history_provider.py +93 -0
- solace_agent_mesh/services/history_service/history_service.py +315 -41
- solace_agent_mesh/services/history_service/long_term_memory/__init__.py +0 -0
- solace_agent_mesh/services/history_service/long_term_memory/long_term_memory.py +399 -0
- solace_agent_mesh/services/llm_service/components/llm_request_component.py +19 -0
- solace_agent_mesh/templates/gateway-config-template.yaml +2 -1
- solace_agent_mesh/templates/gateway-default-config.yaml +3 -3
- solace_agent_mesh/templates/plugin-gateway-default-config.yaml +29 -0
- solace_agent_mesh/templates/rest-api-default-config.yaml +2 -1
- solace_agent_mesh/templates/slack-default-config.yaml +1 -1
- solace_agent_mesh/templates/web-default-config.yaml +2 -1
- {solace_agent_mesh-0.1.3.dist-info → solace_agent_mesh-0.2.0.dist-info}/METADATA +4 -3
- {solace_agent_mesh-0.1.3.dist-info → solace_agent_mesh-0.2.0.dist-info}/RECORD +45 -38
- {solace_agent_mesh-0.1.3.dist-info → solace_agent_mesh-0.2.0.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-0.1.3.dist-info → solace_agent_mesh-0.2.0.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-0.1.3.dist-info → solace_agent_mesh-0.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -54,8 +54,15 @@ class PlantUmlDiagram(Action):
|
|
|
54
54
|
{"role": "user", "content": description},
|
|
55
55
|
]
|
|
56
56
|
agent = self.get_agent()
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
try:
|
|
58
|
+
response = agent.do_llm_service_request(messages=messages)
|
|
59
|
+
expression = response.get("content")
|
|
60
|
+
except TimeoutError as e:
|
|
61
|
+
log.error("LLM request timed out: %s", str(e))
|
|
62
|
+
return ActionResponse(message="LLM request timed out")
|
|
63
|
+
except Exception as e:
|
|
64
|
+
log.error("Failed to process content with LLM: %s", str(e))
|
|
65
|
+
return ActionResponse(message="Failed to process content with LLM")
|
|
59
66
|
|
|
60
67
|
# Surround expression with @startuml and @enduml if missing
|
|
61
68
|
if not expression.startswith("@startuml"):
|
|
@@ -37,46 +37,44 @@ class PlotlyGraph(Action):
|
|
|
37
37
|
],
|
|
38
38
|
"required_scopes": ["global:plotly:read"],
|
|
39
39
|
"examples": [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</example>
|
|
79
|
-
"""
|
|
40
|
+
{
|
|
41
|
+
"docstring": "This is an example of a user asking for a bar graph. The plotly action from the global agent is invoked to generate the graph.",
|
|
42
|
+
"tag_prefix_placeholder": "{tp}",
|
|
43
|
+
"starting_id": "12",
|
|
44
|
+
"user_input": "Please generate a random bar graph for me",
|
|
45
|
+
"metadata": [
|
|
46
|
+
"local_time: 2024-09-04 15:59:02 EDT-0400 (Wednesday)"
|
|
47
|
+
],
|
|
48
|
+
"reasoning": [
|
|
49
|
+
"- user has requested a random bar graph",
|
|
50
|
+
"- invoke the plotly action from the global agent to generate a bar graph with random data"
|
|
51
|
+
],
|
|
52
|
+
"response_text": "Certainly! I'd be happy to generate a random bar graph for you.",
|
|
53
|
+
"status_update": "I'll use our plotting tool to create this for you right away.",
|
|
54
|
+
"action": {
|
|
55
|
+
"agent": "global",
|
|
56
|
+
"name": "plotly",
|
|
57
|
+
"parameter_name": "plotly_figure_config",
|
|
58
|
+
"parameters": {
|
|
59
|
+
"plotly_figure_config": [
|
|
60
|
+
"{{",
|
|
61
|
+
" \"data\": [",
|
|
62
|
+
" {{",
|
|
63
|
+
" \"x\": [\"A\", \"B\", \"C\", \"D\", \"E\"],",
|
|
64
|
+
" \"y\": [23, 45, 56, 78, 90],",
|
|
65
|
+
" \"type\": \"bar\"",
|
|
66
|
+
" }}",
|
|
67
|
+
" ],",
|
|
68
|
+
" \"layout\": {{",
|
|
69
|
+
" \"title\": \"Random Bar Graph\",",
|
|
70
|
+
" \"xaxis\": {{\"title\": \"Categories\"}},",
|
|
71
|
+
" \"yaxis\": {{\"title\": \"Values\"}}",
|
|
72
|
+
" }}",
|
|
73
|
+
"}}"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
80
78
|
],
|
|
81
79
|
},
|
|
82
80
|
**kwargs,
|
|
@@ -31,37 +31,31 @@ class DoWebRequest(Action):
|
|
|
31
31
|
],
|
|
32
32
|
"required_scopes": ["web_request:do_web_request:read"],
|
|
33
33
|
"examples": [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
</{tp}invoke_action>
|
|
60
|
-
|
|
61
|
-
<{tp}status_update>Retrieving the latest weather data for Ottawa...</{tp}status_update>'
|
|
62
|
-
</example_response>
|
|
63
|
-
</example>
|
|
64
|
-
"""
|
|
34
|
+
{
|
|
35
|
+
"docstring": "This is an example of a user requesting to fetch information from the web. The web_request agent is open so invoke the do_web_request action to fetch the content from the url and process the information according to the llm_prompt.",
|
|
36
|
+
"tag_prefix_placeholder": "{tp}",
|
|
37
|
+
"starting_id": "10",
|
|
38
|
+
"user_input": "What is the weather in Ottawa?",
|
|
39
|
+
"metadata": [
|
|
40
|
+
"local_time: 2024-11-06 12:33:12 EST-0500 (Wednesday)"
|
|
41
|
+
],
|
|
42
|
+
"reasoning": [
|
|
43
|
+
"- User is asking for current weather information in Ottawa",
|
|
44
|
+
"- We need to fetch up-to-date weather data",
|
|
45
|
+
"- Use the web_request agent to get the latest weather information",
|
|
46
|
+
"- Plan to use the Environment Canada website for accurate local weather data"
|
|
47
|
+
],
|
|
48
|
+
"response_text": "Certainly! I'll fetch the current weather information for Ottawa for you right away.",
|
|
49
|
+
"status_update": "Retrieving the latest weather data for Ottawa...",
|
|
50
|
+
"action": {
|
|
51
|
+
"agent": "web_request",
|
|
52
|
+
"name": "do_web_request",
|
|
53
|
+
"parameters": {
|
|
54
|
+
"url": "https://weather.gc.ca/city/pages/on-118_metric_e.html",
|
|
55
|
+
"llm_prompt": "Extract the current temperature, weather conditions, and any important weather alerts or warnings for Ottawa from the webpage. Format the response as a bulleted list with emoji where appropriate."
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
65
59
|
],
|
|
66
60
|
},
|
|
67
61
|
**kwargs,
|
|
@@ -127,8 +121,15 @@ class DoWebRequest(Action):
|
|
|
127
121
|
]
|
|
128
122
|
|
|
129
123
|
agent = self.get_agent()
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
try:
|
|
125
|
+
response = agent.do_llm_service_request(messages=messages)
|
|
126
|
+
content = response.get("content")
|
|
127
|
+
except TimeoutError as e:
|
|
128
|
+
log.error("LLM request timed out: %s", str(e))
|
|
129
|
+
return ActionResponse(message="LLM request timed out")
|
|
130
|
+
except Exception as e:
|
|
131
|
+
log.error("Failed to process content with LLM: %s", str(e))
|
|
132
|
+
return ActionResponse(message="Failed to process content with LLM")
|
|
132
133
|
|
|
133
134
|
# Code to create the image using the provided content
|
|
134
135
|
return ActionResponse(message=content)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.2.0"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
3
|
import click
|
|
4
|
+
import re
|
|
4
5
|
|
|
5
|
-
from cli.utils import get_display_path, load_template, log_error, get_formatted_names
|
|
6
|
+
from cli.utils import get_display_path, load_template, log_error, get_formatted_names, log_warning
|
|
6
7
|
from cli.commands.plugin.build import get_all_plugin_gateway_interfaces
|
|
7
8
|
from cli.config import Config
|
|
8
9
|
|
|
@@ -34,6 +35,126 @@ def _add_python_files(modules_directory, template_args, created_file_names):
|
|
|
34
35
|
f.write(gateway_template)
|
|
35
36
|
created_file_names.append(gateway_path)
|
|
36
37
|
|
|
38
|
+
def _update_gateway_yaml(yaml_string, interface_gateway_config):
|
|
39
|
+
# Update system_purpose
|
|
40
|
+
if "system_purpose" in interface_gateway_config:
|
|
41
|
+
yaml_string = re.sub(
|
|
42
|
+
r'(system_purpose: >\n\s+)(.*?)(?=\n\s{4}\S)',
|
|
43
|
+
lambda m: f'{m.group(1)}{interface_gateway_config["system_purpose"]}',
|
|
44
|
+
yaml_string,
|
|
45
|
+
flags=re.DOTALL
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Update interaction_type
|
|
49
|
+
if "interaction_type" in interface_gateway_config:
|
|
50
|
+
yaml_string = re.sub(
|
|
51
|
+
r'(interaction_type: )".*?"',
|
|
52
|
+
lambda m: f'{m.group(1)}"{interface_gateway_config["interaction_type"]}"',
|
|
53
|
+
yaml_string
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Update history settings
|
|
57
|
+
history_config = interface_gateway_config.get("history", {})
|
|
58
|
+
if not history_config.get("enabled", False):
|
|
59
|
+
yaml_string = re.sub(r'\n\s+history_config: \n\s+<<: \*default_history_policy', '', yaml_string)
|
|
60
|
+
yaml_string = re.sub(r'(retain_history: )true', r'\1false', yaml_string)
|
|
61
|
+
yaml_string = re.sub(
|
|
62
|
+
r'\n- history_policy:.*?(?=\n\n)',
|
|
63
|
+
'',
|
|
64
|
+
yaml_string,
|
|
65
|
+
flags=re.DOTALL
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
else:
|
|
69
|
+
if history_config.get("type") is not None:
|
|
70
|
+
yaml_string = re.sub(
|
|
71
|
+
r'(type: )".*?"',
|
|
72
|
+
lambda m: f'{m.group(1)}"{history_config.get("type")}"',
|
|
73
|
+
yaml_string,
|
|
74
|
+
count=1 # Update only the first occurrence
|
|
75
|
+
)
|
|
76
|
+
if history_config.get("time_to_live") is not None:
|
|
77
|
+
yaml_string = re.sub(
|
|
78
|
+
r'(time_to_live: )\d+',
|
|
79
|
+
lambda m: f'{m.group(1)}{history_config.get("time_to_live")}',
|
|
80
|
+
yaml_string
|
|
81
|
+
)
|
|
82
|
+
if history_config.get("expiration_check_interval") is not None:
|
|
83
|
+
yaml_string = re.sub(
|
|
84
|
+
r'(expiration_check_interval: )\d+',
|
|
85
|
+
lambda m: f'{m.group(1)}{history_config.get("expiration_check_interval")}',
|
|
86
|
+
yaml_string
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if history_config.get("max_turns") is not None:
|
|
90
|
+
yaml_string = re.sub(
|
|
91
|
+
r'(max_turns: )\d+',
|
|
92
|
+
lambda m: f'{m.group(1)}{history_config.get("max_turns")}',
|
|
93
|
+
yaml_string
|
|
94
|
+
)
|
|
95
|
+
if history_config.get("max_characters") is not None:
|
|
96
|
+
yaml_string = re.sub(
|
|
97
|
+
r'(max_characters: )\d+',
|
|
98
|
+
lambda m: f'{m.group(1)}{history_config.get("max_characters")}',
|
|
99
|
+
yaml_string
|
|
100
|
+
)
|
|
101
|
+
if history_config.get("enforce_alternate_message_roles") is not None:
|
|
102
|
+
yaml_string = re.sub(
|
|
103
|
+
r'(enforce_alternate_message_roles: )\w+',
|
|
104
|
+
lambda m: f'{m.group(1)}{str(history_config.get("enforce_alternate_message_roles", True)).lower()}',
|
|
105
|
+
yaml_string
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Inject long-term memory before history_policy
|
|
109
|
+
if history_config.get("long_term_memory", {}).get("enabled", False):
|
|
110
|
+
# Build llm_config string
|
|
111
|
+
llm_config_items = history_config['long_term_memory'].get('llm_config', {})
|
|
112
|
+
if llm_config_items:
|
|
113
|
+
llm_config_parts = []
|
|
114
|
+
for key, value in llm_config_items.items():
|
|
115
|
+
llm_config_parts.append(f"{key}: {value}")
|
|
116
|
+
llm_config = "\n " + "\n ".join(llm_config_parts) + "\n"
|
|
117
|
+
else:
|
|
118
|
+
llm_config = " {} \n"
|
|
119
|
+
|
|
120
|
+
# Build store_config string
|
|
121
|
+
store_config_items = history_config['long_term_memory'].get('store_config', {})
|
|
122
|
+
if store_config_items:
|
|
123
|
+
store_config_parts = []
|
|
124
|
+
for key, value in store_config_items.items():
|
|
125
|
+
store_config_parts.append(f"{key}: {value}")
|
|
126
|
+
store_config = "\n " + "\n ".join(store_config_parts) + "\n"
|
|
127
|
+
else:
|
|
128
|
+
store_config = " {} \n"
|
|
129
|
+
long_term_yaml = (
|
|
130
|
+
'long_term_memory: true\n'
|
|
131
|
+
' long_term_memory_config:\n'
|
|
132
|
+
f' llm_config:{llm_config}'
|
|
133
|
+
f' store_config:{store_config}'
|
|
134
|
+
' '
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
if "long_term_memory:" not in yaml_string:
|
|
138
|
+
yaml_string = re.sub(
|
|
139
|
+
r'(history_policy: # History provider configs.*?\n(\s+max_turns: \d+))',
|
|
140
|
+
lambda m: f'{long_term_yaml}{m.group(1)}',
|
|
141
|
+
yaml_string,
|
|
142
|
+
flags=re.DOTALL
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# Inject type_config under history_policy
|
|
146
|
+
type_config = history_config.get("type_config", {})
|
|
147
|
+
if type_config:
|
|
148
|
+
type_config_yaml = '\n'.join([f' {key}: {value}' for key, value in type_config.items()])
|
|
149
|
+
yaml_string = re.sub(
|
|
150
|
+
r'(history_policy: # History provider configs.*?)\n',
|
|
151
|
+
lambda m: f'{m.group(1)}\n{type_config_yaml}\n',
|
|
152
|
+
yaml_string,
|
|
153
|
+
flags=re.DOTALL
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
return yaml_string
|
|
157
|
+
|
|
37
158
|
def add_gateway_command(name, interfaces):
|
|
38
159
|
"""
|
|
39
160
|
Creates a gateway configuration directory and files based on provided templates.
|
|
@@ -76,7 +197,7 @@ def add_gateway_command(name, interfaces):
|
|
|
76
197
|
def abort():
|
|
77
198
|
sys.exit(1)
|
|
78
199
|
|
|
79
|
-
plugin_gateway_interfaces = get_all_plugin_gateway_interfaces(config, abort)
|
|
200
|
+
plugin_gateway_interfaces = get_all_plugin_gateway_interfaces(config, abort, return_plugin_config=True)
|
|
80
201
|
|
|
81
202
|
# Check if the gateway directory already exists
|
|
82
203
|
if os.path.exists(gateway_directory):
|
|
@@ -91,12 +212,11 @@ def add_gateway_command(name, interfaces):
|
|
|
91
212
|
|
|
92
213
|
# Create the gateway config file from the template directory
|
|
93
214
|
# The file name is gateway-default-config.yaml but write it as gateway.yaml in the gateway_directory
|
|
94
|
-
gateway_config_template = load_template("gateway-default-config.yaml")
|
|
95
215
|
gateway_config_path = os.path.join(gateway_directory, "gateway.yaml")
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
216
|
+
gateway_config_default = load_template("gateway-default-config.yaml")
|
|
217
|
+
gateway_config = gateway_config_default
|
|
218
|
+
gateway_config_interface_default_name = None # the interface name that is used for the default gateway config
|
|
219
|
+
gateway_config_overwritten = False
|
|
100
220
|
|
|
101
221
|
# If the interface list is not empty, create the interface config files
|
|
102
222
|
if interfaces:
|
|
@@ -105,8 +225,17 @@ def add_gateway_command(name, interfaces):
|
|
|
105
225
|
# The name will be {interface}-default-config.yaml
|
|
106
226
|
# Write the file as {interface}.yaml in the gateway_directory
|
|
107
227
|
if interface in plugin_gateway_interfaces:
|
|
228
|
+
interface_gateway_config = plugin_gateway_interfaces[interface][1]
|
|
229
|
+
# Checking if the interface has default values for the gateway.yaml
|
|
230
|
+
if interface_gateway_config:
|
|
231
|
+
# Checking if another interface has already been used to create the gateway.yaml
|
|
232
|
+
if gateway_config_interface_default_name:
|
|
233
|
+
# Overwrite the default gateway config with the current interface config
|
|
234
|
+
gateway_config_overwritten = True
|
|
235
|
+
gateway_config_interface_default_name = interface
|
|
236
|
+
gateway_config = _update_gateway_yaml(gateway_config_default, interface_gateway_config)
|
|
108
237
|
interface_default_path = os.path.join(
|
|
109
|
-
plugin_gateway_interfaces[interface],
|
|
238
|
+
plugin_gateway_interfaces[interface][0],
|
|
110
239
|
f"{interface}-default-config.yaml",
|
|
111
240
|
)
|
|
112
241
|
if not os.path.exists(interface_default_path):
|
|
@@ -149,6 +278,17 @@ def add_gateway_command(name, interfaces):
|
|
|
149
278
|
log_error(f"Error creating gateway, gateway config was created: {e}")
|
|
150
279
|
return 1
|
|
151
280
|
|
|
281
|
+
with open(gateway_config_path, "w", encoding="utf-8") as f:
|
|
282
|
+
f.write(gateway_config)
|
|
283
|
+
|
|
284
|
+
if gateway_config_overwritten:
|
|
285
|
+
log_warning(("Multiple interface configurations found. "
|
|
286
|
+
"Overwriting default gateway configuration with "
|
|
287
|
+
f"{gateway_config_interface_default_name} interface configuration."
|
|
288
|
+
))
|
|
289
|
+
|
|
290
|
+
created_file_names.append(gateway_config_path)
|
|
291
|
+
|
|
152
292
|
temp_file = os.path.join(config_directory, "__TEMPLATES_WILL_BE_HERE__")
|
|
153
293
|
if os.path.exists(temp_file):
|
|
154
294
|
os.remove(temp_file)
|
|
@@ -169,7 +309,8 @@ def add_interface_command(name):
|
|
|
169
309
|
Creates a new gateway interface with the provided name.
|
|
170
310
|
"""
|
|
171
311
|
config = Config.get_plugin_config()
|
|
172
|
-
|
|
312
|
+
plugin_config = config.get("solace_agent_mesh_plugin", {})
|
|
313
|
+
plugin_name = plugin_config.get("name")
|
|
173
314
|
if not plugin_name or plugin_name == "solace-agent-mesh-plugin":
|
|
174
315
|
log_error("Could not find a valid plugin project")
|
|
175
316
|
return 1
|
|
@@ -210,6 +351,18 @@ def add_interface_command(name):
|
|
|
210
351
|
|
|
211
352
|
_add_python_files(modules_directory, template_args, created_file_names)
|
|
212
353
|
|
|
354
|
+
# Update the 'solace-agent-mesh-plugin' configuration file
|
|
355
|
+
plugin_config["includes_gateway_interface"] = True
|
|
356
|
+
plugin_gateway_config_template = load_template("plugin-gateway-default-config.yaml", parser=Config.get_yaml_parser())
|
|
357
|
+
if not plugin_gateway_config_template:
|
|
358
|
+
log_error("Error: Plugin gateway config template not found.")
|
|
359
|
+
else:
|
|
360
|
+
if "interface_gateway_configs" not in plugin_config:
|
|
361
|
+
plugin_config["interface_gateway_configs"] = {}
|
|
362
|
+
plugin_config["interface_gateway_configs"][template_args["HYPHENED_NAME"]] = plugin_gateway_config_template.get("plugin_gateway_default_config", {})
|
|
363
|
+
Config.write_config(config, Config.user_plugin_config_file)
|
|
364
|
+
click.echo(f"Updated {Config.user_plugin_config_file} with default gateway interface configuration for {template_args['HYPHENED_NAME']}")
|
|
365
|
+
|
|
213
366
|
except IOError as e:
|
|
214
367
|
log_error(f"Error creating gateway interface, {e}")
|
|
215
368
|
return 1
|
|
@@ -17,6 +17,57 @@ def add_pair_to_file_if_not_exists(file_path, pairs):
|
|
|
17
17
|
f.write(f"{key}{value}\n")
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def update_or_add_pairs_to_file(file_path, pairs):
|
|
21
|
+
"""
|
|
22
|
+
Updates existing key-value pairs in a file or adds them if they don't exist.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
file_path (str): The path to the file to update
|
|
26
|
+
pairs (list): A list of (key, value) tuples to update or add
|
|
27
|
+
"""
|
|
28
|
+
# Check if file exists
|
|
29
|
+
if os.path.exists(file_path):
|
|
30
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
31
|
+
lines = f.readlines()
|
|
32
|
+
else:
|
|
33
|
+
lines = []
|
|
34
|
+
|
|
35
|
+
# Create a dictionary of key-value pairs for quick lookup
|
|
36
|
+
pair_dict = {key: value for key, value in pairs}
|
|
37
|
+
updated_keys = set()
|
|
38
|
+
|
|
39
|
+
# Process each line
|
|
40
|
+
new_lines = []
|
|
41
|
+
for line in lines:
|
|
42
|
+
line = line.rstrip()
|
|
43
|
+
if not line or line.startswith("#"):
|
|
44
|
+
# Keep comments and empty lines
|
|
45
|
+
new_lines.append(line)
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
# Check if line contains any of our keys
|
|
49
|
+
found_key = None
|
|
50
|
+
for key in pair_dict:
|
|
51
|
+
if line.startswith(key + "=") or line.startswith(key + " ="):
|
|
52
|
+
found_key = key
|
|
53
|
+
updated_keys.add(key)
|
|
54
|
+
new_lines.append(f"{key}{pair_dict[key]}")
|
|
55
|
+
break
|
|
56
|
+
|
|
57
|
+
if not found_key:
|
|
58
|
+
# Keep lines that don't match our keys
|
|
59
|
+
new_lines.append(line)
|
|
60
|
+
|
|
61
|
+
# Add any new variables that weren't found
|
|
62
|
+
for key, value in pairs:
|
|
63
|
+
if key not in updated_keys:
|
|
64
|
+
new_lines.append(f"{key}{value}")
|
|
65
|
+
|
|
66
|
+
# Write the updated content back to the file
|
|
67
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
68
|
+
f.write("\n".join(new_lines) + "\n")
|
|
69
|
+
|
|
70
|
+
|
|
20
71
|
def create_other_project_files_step(options, default_options, none_interactive, abort):
|
|
21
72
|
"""
|
|
22
73
|
Creates the other project files. i.e. .gitignore, .env, requirements.txt, etc.
|
|
@@ -92,5 +143,5 @@ def create_other_project_files_step(options, default_options, none_interactive,
|
|
|
92
143
|
required_env_variables.append((key, f"={value}"))
|
|
93
144
|
|
|
94
145
|
create_if_not_exists(options["env_file"], "")
|
|
95
|
-
|
|
146
|
+
update_or_add_pairs_to_file(options["env_file"], required_env_variables)
|
|
96
147
|
add_gateway_command(options["rest_api_gateway_name"],["rest-api"])
|
|
@@ -11,7 +11,7 @@ def build_command():
|
|
|
11
11
|
subprocess.check_call(["python", "-m", "build"])
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def get_all_plugin_gateway_interfaces(config, abort):
|
|
14
|
+
def get_all_plugin_gateway_interfaces(config, abort, return_plugin_config=False):
|
|
15
15
|
plugins = config.get("plugins", [])
|
|
16
16
|
gateway_interfaces = {}
|
|
17
17
|
|
|
@@ -27,6 +27,8 @@ def get_all_plugin_gateway_interfaces(config, abort):
|
|
|
27
27
|
if not os.path.exists(interface_path):
|
|
28
28
|
continue
|
|
29
29
|
|
|
30
|
+
interface_gateway_configs = (Config.load_config(os.path.join(plugin_path, Config.user_plugin_config_file)) or {}).get("solace_agent_mesh_plugin", {}).get("interface_gateway_configs", {})
|
|
31
|
+
interface_gateway_config = None
|
|
30
32
|
# Ensuring flow and default pair exist
|
|
31
33
|
interface_pairs = {}
|
|
32
34
|
for file in os.listdir(interface_path):
|
|
@@ -44,7 +46,14 @@ def get_all_plugin_gateway_interfaces(config, abort):
|
|
|
44
46
|
|
|
45
47
|
for name, files in interface_pairs.items():
|
|
46
48
|
if len(files) == 2:
|
|
47
|
-
|
|
49
|
+
if return_plugin_config:
|
|
50
|
+
for interface_name, interface_config in interface_gateway_configs.items():
|
|
51
|
+
if interface_name == name.replace("-", "_"):
|
|
52
|
+
interface_gateway_config = interface_config
|
|
53
|
+
break
|
|
54
|
+
gateway_interfaces[name] = (interface_path, interface_gateway_config)
|
|
55
|
+
else:
|
|
56
|
+
gateway_interfaces[name] = interface_path
|
|
48
57
|
|
|
49
58
|
return gateway_interfaces
|
|
50
59
|
|
solace_agent_mesh/cli/config.py
CHANGED
solace_agent_mesh/cli/utils.py
CHANGED
|
@@ -42,7 +42,7 @@ def literal_format_template(template, literals):
|
|
|
42
42
|
return template
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def load_template(name, format_pair={}):
|
|
45
|
+
def load_template(name, format_pair={}, parser=None):
|
|
46
46
|
"""Load a template file and format it with the given key-value pairs."""
|
|
47
47
|
# Construct the path to the template file using a relative path
|
|
48
48
|
template_file = os.path.normpath(
|
|
@@ -53,7 +53,10 @@ def load_template(name, format_pair={}):
|
|
|
53
53
|
return None
|
|
54
54
|
|
|
55
55
|
with open(template_file, "r", encoding="utf-8") as f:
|
|
56
|
-
|
|
56
|
+
if parser:
|
|
57
|
+
file = parser(f)
|
|
58
|
+
else:
|
|
59
|
+
file = f.read()
|
|
57
60
|
|
|
58
61
|
file = literal_format_template(file, format_pair)
|
|
59
62
|
|
|
@@ -75,6 +78,8 @@ def get_display_path(path):
|
|
|
75
78
|
def log_error(message):
|
|
76
79
|
click.echo(click.style(message, fg="red"), err=True)
|
|
77
80
|
|
|
81
|
+
def log_warning(message):
|
|
82
|
+
click.echo(click.style(message, fg="yellow"), err=False)
|
|
78
83
|
|
|
79
84
|
def log_link(message):
|
|
80
85
|
click.echo(click.style(message, fg="blue"), err=False)
|
|
@@ -3,3 +3,13 @@ SOLACE_AGENT_MESH_SYSTEM_SESSION_ID = "solace_agent_mesh_system_session_id"
|
|
|
3
3
|
DEFAULT_IDENTITY_KEY_FIELD = "identity"
|
|
4
4
|
|
|
5
5
|
ORCHESTRATOR_COMPONENT_NAME = "orchestrator"
|
|
6
|
+
|
|
7
|
+
HISTORY_MEMORY_ROLE = "history"
|
|
8
|
+
|
|
9
|
+
HISTORY_ACTION_ROLE = "tool_call"
|
|
10
|
+
|
|
11
|
+
HISTORY_USER_ROLE = "user"
|
|
12
|
+
|
|
13
|
+
HISTORY_SYSTEM_ROLE = "system"
|
|
14
|
+
|
|
15
|
+
HISTORY_ASSISTANT_ROLE = "assistant"
|
|
@@ -139,17 +139,22 @@ def parse_file_content(file_xml: str) -> dict:
|
|
|
139
139
|
"""
|
|
140
140
|
Parse the xml tags in the content and return a dictionary of the content.
|
|
141
141
|
"""
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
try:
|
|
143
|
+
ignore_content_tags = ["data"]
|
|
144
|
+
file_dict = xml_to_dict(file_xml, ignore_content_tags)
|
|
145
|
+
dict_keys = list(file_dict.keys())
|
|
146
|
+
top_key = [key for key in dict_keys if key not in ignore_content_tags][0]
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
"data": file_dict.get("data", {}).get("data", ""),
|
|
150
|
+
"url": file_dict.get(top_key, {}).get("url", {}).get("url", ""),
|
|
151
|
+
"mime_type": file_dict.get(top_key, {}).get("mime_type", ""),
|
|
152
|
+
"name": file_dict.get(top_key, {}).get("name", ""),
|
|
153
|
+
}
|
|
154
|
+
except Exception as e:
|
|
155
|
+
result = {"data": "", "url": "", "mime_type": "", "name": ""}
|
|
156
|
+
log.error("Error parsing file content: %s", e)
|
|
157
|
+
return result
|
|
153
158
|
|
|
154
159
|
|
|
155
160
|
def parse_llm_output(llm_output: str) -> dict:
|