solace-agent-mesh 1.0.7__py3-none-any.whl → 1.1.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/agent/adk/adk_llm.txt +182 -42
- solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +171 -0
- solace_agent_mesh/agent/adk/callbacks.py +165 -104
- solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +0 -18
- solace_agent_mesh/agent/adk/models/models_llm.txt +104 -55
- solace_agent_mesh/agent/adk/runner.py +7 -5
- solace_agent_mesh/agent/adk/services.py +9 -1
- solace_agent_mesh/agent/adk/setup.py +11 -0
- solace_agent_mesh/agent/adk/stream_parser.py +8 -1
- solace_agent_mesh/agent/adk/tool_wrapper.py +10 -3
- solace_agent_mesh/agent/agent_llm.txt +355 -18
- solace_agent_mesh/agent/protocol/event_handlers.py +433 -296
- solace_agent_mesh/agent/protocol/protocol_llm.txt +54 -7
- solace_agent_mesh/agent/sac/app.py +1 -1
- solace_agent_mesh/agent/sac/component.py +212 -517
- solace_agent_mesh/agent/sac/sac_llm.txt +133 -63
- solace_agent_mesh/agent/testing/testing_llm.txt +25 -58
- solace_agent_mesh/agent/tools/peer_agent_tool.py +15 -11
- solace_agent_mesh/agent/tools/tools_llm.txt +234 -69
- solace_agent_mesh/agent/utils/artifact_helpers.py +35 -1
- solace_agent_mesh/agent/utils/utils_llm.txt +90 -105
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/{3d406171.7d02a73b.js → 3d406171.0b9eeed1.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/6e0db977.39a79ca9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{75384d09.ccd480c4.js → 75384d09.bf78fbdb.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/90dd9cf6.88f385ea.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f284c35a.fb68323a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.a75ecc0d.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.458efb1d.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +105 -0
- solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-technical-migration-map/index.html +53 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +4 -4
- solace_agent_mesh/assets/docs/lunr-index-1756992446316.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1756992446316.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/assets/docs/sitemap.xml +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add_cmd/web_add_agent_step.py +12 -3
- solace_agent_mesh/cli/commands/add_cmd/web_add_gateway_step.py +10 -14
- solace_agent_mesh/cli/commands/init_cmd/web_init_step.py +2 -15
- solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +6 -2
- solace_agent_mesh/cli/utils.py +15 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-DvlO62me.js → authCallback-BmF2l6vg.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{client-bp6u3qVZ.js → client-D881Dttc.js} +4 -4
- solace_agent_mesh/client/webui/frontend/static/assets/main-C0jZjYa8.js +699 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-CCeG324-.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +2 -2
- solace_agent_mesh/client/webui/frontend/static/index.html +3 -3
- solace_agent_mesh/common/a2a/__init__.py +213 -0
- solace_agent_mesh/common/a2a/a2a_llm.txt +182 -0
- solace_agent_mesh/common/a2a/artifact.py +328 -0
- solace_agent_mesh/common/a2a/events.py +183 -0
- solace_agent_mesh/common/a2a/message.py +307 -0
- solace_agent_mesh/common/a2a/protocol.py +513 -0
- solace_agent_mesh/common/a2a/task.py +127 -0
- solace_agent_mesh/common/a2a/translation.py +653 -0
- solace_agent_mesh/common/a2a/types.py +54 -0
- solace_agent_mesh/common/a2a_spec/a2a.json +2576 -0
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +407 -0
- solace_agent_mesh/common/a2a_spec/schemas/agent_progress_update.json +18 -0
- solace_agent_mesh/common/a2a_spec/schemas/artifact_creation_progress.json +31 -0
- solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +18 -0
- solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +235 -0
- solace_agent_mesh/common/a2a_spec/schemas/tool_invocation_start.json +26 -0
- solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +25 -0
- solace_agent_mesh/common/agent_registry.py +1 -1
- solace_agent_mesh/common/common_llm.txt +192 -70
- solace_agent_mesh/common/data_parts.py +99 -0
- solace_agent_mesh/common/middleware/middleware_llm.txt +17 -17
- solace_agent_mesh/common/sac/__init__.py +0 -0
- solace_agent_mesh/common/sac/sac_llm.txt +71 -0
- solace_agent_mesh/common/sac/sam_component_base.py +252 -0
- solace_agent_mesh/common/services/providers/providers_llm.txt +51 -84
- solace_agent_mesh/common/services/services_llm.txt +206 -26
- solace_agent_mesh/common/utils/artifact_utils.py +29 -0
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +176 -80
- solace_agent_mesh/common/utils/utils_llm.txt +323 -42
- solace_agent_mesh/config_portal/backend/common.py +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{_index-MqsrTd6g.js → _index-Bym6YkMd.js} +74 -24
- solace_agent_mesh/config_portal/frontend/static/client/assets/{components-B7lKcHVY.js → components-Rk0n-9cK.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-CEumGClk.js → entry.client-mvZjNKiz.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{index-DSo1AH_7.js → index-DzNKzXrc.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-d845808d.js +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{root-C4XmHinv.js → root-BWvk5-gF.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
- solace_agent_mesh/core_a2a/core_a2a_llm.txt +10 -8
- solace_agent_mesh/core_a2a/service.py +20 -44
- solace_agent_mesh/gateway/base/app.py +27 -1
- solace_agent_mesh/gateway/base/base_llm.txt +177 -72
- solace_agent_mesh/gateway/base/component.py +294 -523
- solace_agent_mesh/gateway/gateway_llm.txt +299 -58
- solace_agent_mesh/gateway/http_sse/component.py +156 -183
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +29 -29
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +272 -36
- solace_agent_mesh/gateway/http_sse/main.py +8 -10
- solace_agent_mesh/gateway/http_sse/routers/agents.py +1 -1
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +18 -4
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +231 -5
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +12 -7
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +116 -169
- solace_agent_mesh/gateway/http_sse/services/agent_service.py +1 -1
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +89 -135
- solace_agent_mesh/gateway/http_sse/services/task_service.py +2 -5
- solace_agent_mesh/solace_agent_mesh_llm.txt +362 -0
- solace_agent_mesh/templates/gateway_component_template.py +149 -98
- {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/METADATA +5 -4
- {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/RECORD +144 -127
- solace_agent_mesh/assets/docs/assets/js/f284c35a.731836ad.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/main.d79f063b.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/runtime~main.6415ad00.js +0 -1
- solace_agent_mesh/assets/docs/lunr-index-1756146501924.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1756146501924.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-BCpII1-0.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-BucUdn9m.js +0 -673
- solace_agent_mesh/common/a2a_protocol.py +0 -564
- solace_agent_mesh/common/client/__init__.py +0 -4
- solace_agent_mesh/common/client/card_resolver.py +0 -21
- solace_agent_mesh/common/client/client.py +0 -85
- solace_agent_mesh/common/client/client_llm.txt +0 -133
- solace_agent_mesh/common/server/__init__.py +0 -4
- solace_agent_mesh/common/server/server.py +0 -122
- solace_agent_mesh/common/server/server_llm.txt +0 -169
- solace_agent_mesh/common/server/task_manager.py +0 -291
- solace_agent_mesh/common/server/utils.py +0 -28
- solace_agent_mesh/common/types.py +0 -411
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-28271392.js +0 -1
- /solace_agent_mesh/assets/docs/assets/js/{main.d79f063b.js.LICENSE.txt → main.a75ecc0d.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,124 +1,220 @@
|
|
|
1
|
-
|
|
1
|
+
# DEVELOPER GUIDE: embeds
|
|
2
2
|
|
|
3
3
|
## Quick Summary
|
|
4
|
-
The `embeds` directory provides a system for finding, parsing, and resolving embedded expressions within strings. These expressions
|
|
4
|
+
The `embeds` directory provides a comprehensive system for finding, parsing, and resolving embedded expressions within strings. These expressions use `«...»` syntax and can represent dynamic values like mathematical calculations, datetimes, UUIDs, or content from stored artifacts. The system supports multi-step data transformation pipelines, recursive embed resolution, and includes safety features like depth and size limits. It's designed as a core component for dynamic content generation and data processing in agent workflows.
|
|
5
5
|
|
|
6
6
|
## Files Overview
|
|
7
|
-
- `__init__.py
|
|
8
|
-
- `constants.py
|
|
9
|
-
- `converter.py
|
|
10
|
-
- `evaluators.py
|
|
11
|
-
- `modifiers.py
|
|
12
|
-
- `resolver.py
|
|
13
|
-
- `types.py
|
|
7
|
+
- `__init__.py` - Main public entry point exporting key functions and constants
|
|
8
|
+
- `constants.py` - Defines embed syntax (delimiters, separators), regex patterns, and type classifications
|
|
9
|
+
- `converter.py` - Data format conversion and serialization functions
|
|
10
|
+
- `evaluators.py` - Specific evaluation logic for simple embed types (math, datetime, uuid, etc.)
|
|
11
|
+
- `modifiers.py` - Data transformation functions that can be chained together (jsonpath, slice, grep, etc.)
|
|
12
|
+
- `resolver.py` - Core orchestration engine handling embed resolution, modifier chains, and recursion
|
|
13
|
+
- `types.py` - DataFormat enum for tracking data types during transformations
|
|
14
14
|
|
|
15
15
|
## Developer API Reference
|
|
16
16
|
|
|
17
17
|
### __init__.py
|
|
18
|
-
**Purpose:**
|
|
18
|
+
**Purpose:** Main public entry point that exports the most commonly used functions and constants from other modules.
|
|
19
19
|
|
|
20
|
-
**Import:** `from
|
|
21
|
-
|
|
22
|
-
*(Note: Detailed documentation is available under each source file's section.)*
|
|
23
|
-
|
|
24
|
-
**Classes:**
|
|
25
|
-
- None
|
|
20
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds import resolve_embeds_recursively_in_string, evaluate_embed, EMBED_REGEX`
|
|
26
21
|
|
|
27
22
|
**Functions:**
|
|
28
|
-
- `evaluate_embed(
|
|
29
|
-
- `resolve_embeds_in_string(
|
|
30
|
-
- `resolve_embeds_recursively_in_string(
|
|
23
|
+
- `evaluate_embed(embed_type: str, expression: str, format_spec: Optional[str], context: Dict[str, Any], log_identifier: str, config: Optional[Dict] = None, current_depth: int = 0, visited_artifacts: Optional[Set[Tuple[str, int]]] = None) -> Union[Tuple[str, Optional[str], int], Tuple[None, str, Any]]` - Evaluates a single parsed embed expression
|
|
24
|
+
- `resolve_embeds_in_string(text: str, context: Any, resolver_func: Callable, types_to_resolve: Set[str], log_identifier: str = "[EmbedUtil]", config: Optional[Dict[str, Any]] = None) -> Tuple[str, int, List[Tuple[int, Any]]]` - Resolves embeds in a string for a single pass (non-recursive)
|
|
25
|
+
- `resolve_embeds_recursively_in_string(text: str, context: Any, resolver_func: Callable, types_to_resolve: Set[str], log_identifier: str, config: Optional[Dict], max_depth: int, current_depth: int = 0, visited_artifacts: Optional[Set[Tuple[str, int]]] = None, accumulated_size: int = 0, max_total_size: int = -1) -> str` - Recursively resolves all embeds in a string with depth and size limits
|
|
31
26
|
|
|
32
27
|
**Constants/Variables:**
|
|
33
|
-
- `EMBED_DELIMITER_OPEN: str
|
|
34
|
-
- `EMBED_DELIMITER_CLOSE: str
|
|
35
|
-
- `EMBED_TYPE_SEPARATOR: str
|
|
36
|
-
- `EMBED_FORMAT_SEPARATOR: str
|
|
37
|
-
- `EMBED_CHAIN_DELIMITER: str
|
|
38
|
-
- `EMBED_REGEX: re.Pattern
|
|
39
|
-
- `EARLY_EMBED_TYPES: Set[str]
|
|
40
|
-
- `LATE_EMBED_TYPES: Set[str]
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
### constants.py
|
|
44
|
-
**Purpose:** This file defines all the static constants that govern the syntax and classification of embeds. This includes delimiters, separators, the master regular expression for parsing, and sets that categorize embed types for phased resolution.
|
|
28
|
+
- `EMBED_DELIMITER_OPEN: str` - Opening delimiter (`«`)
|
|
29
|
+
- `EMBED_DELIMITER_CLOSE: str` - Closing delimiter (`»`)
|
|
30
|
+
- `EMBED_TYPE_SEPARATOR: str` - Type/expression separator (`:`)
|
|
31
|
+
- `EMBED_FORMAT_SEPARATOR: str` - Format specifier separator (`|`)
|
|
32
|
+
- `EMBED_CHAIN_DELIMITER: str` - Modifier chain separator (`>>>`)
|
|
33
|
+
- `EMBED_REGEX: re.Pattern` - Compiled regex for finding embeds
|
|
34
|
+
- `EARLY_EMBED_TYPES: Set[str]` - Types resolved in initial pass
|
|
35
|
+
- `LATE_EMBED_TYPES: Set[str]` - Types resolved in subsequent pass
|
|
45
36
|
|
|
46
|
-
**
|
|
37
|
+
**Usage Examples:**
|
|
38
|
+
```python
|
|
39
|
+
from solace_agent_mesh.common.utils.embeds import resolve_embeds_recursively_in_string, evaluate_embed, EMBED_REGEX
|
|
40
|
+
|
|
41
|
+
# Basic embed resolution
|
|
42
|
+
context = {
|
|
43
|
+
"artifact_service": my_artifact_service,
|
|
44
|
+
"session_context": {"app_name": "myapp", "user_id": "user123", "session_id": "sess456"}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
text = "The result is «math:10 * 1.15 | .2f» and ID is «uuid:new»"
|
|
48
|
+
resolved = await resolve_embeds_recursively_in_string(
|
|
49
|
+
text=text,
|
|
50
|
+
context=context,
|
|
51
|
+
resolver_func=evaluate_embed,
|
|
52
|
+
types_to_resolve={"math", "uuid"},
|
|
53
|
+
log_identifier="[MyApp]",
|
|
54
|
+
config={},
|
|
55
|
+
max_depth=5
|
|
56
|
+
)
|
|
57
|
+
```
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
### constants.py
|
|
60
|
+
**Purpose:** Defines all static constants governing embed syntax and classification.
|
|
50
61
|
|
|
51
|
-
**
|
|
52
|
-
- None
|
|
62
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds.constants import EMBED_REGEX, EARLY_EMBED_TYPES`
|
|
53
63
|
|
|
54
64
|
**Constants/Variables:**
|
|
55
|
-
- `EMBED_DELIMITER_OPEN: str
|
|
56
|
-
- `EMBED_DELIMITER_CLOSE: str
|
|
57
|
-
- `EMBED_TYPE_SEPARATOR: str
|
|
58
|
-
- `EMBED_FORMAT_SEPARATOR: str
|
|
59
|
-
- `EMBED_CHAIN_DELIMITER: str
|
|
60
|
-
- `EMBED_REGEX: re.Pattern
|
|
61
|
-
- `EARLY_EMBED_TYPES: Set[str]
|
|
62
|
-
- `LATE_EMBED_TYPES: Set[str]
|
|
63
|
-
- `TEXT_CONTAINER_MIME_TYPES: Set[str]
|
|
65
|
+
- `EMBED_DELIMITER_OPEN: str` - Opening delimiter (`«`)
|
|
66
|
+
- `EMBED_DELIMITER_CLOSE: str` - Closing delimiter (`»`)
|
|
67
|
+
- `EMBED_TYPE_SEPARATOR: str` - Type/expression separator (`:`)
|
|
68
|
+
- `EMBED_FORMAT_SEPARATOR: str` - Format specifier separator (`|`)
|
|
69
|
+
- `EMBED_CHAIN_DELIMITER: str` - Modifier chain separator (`>>>`)
|
|
70
|
+
- `EMBED_REGEX: re.Pattern` - Compiled regex with capture groups for type, expression, and format
|
|
71
|
+
- `EARLY_EMBED_TYPES: Set[str]` - Simple embed types resolved first (`math`, `datetime`, `uuid`, `artifact_meta`, `status_update`)
|
|
72
|
+
- `LATE_EMBED_TYPES: Set[str]` - Complex embed types resolved later (`artifact_content`)
|
|
73
|
+
- `TEXT_CONTAINER_MIME_TYPES: Set[str]` - MIME types considered text-based
|
|
64
74
|
|
|
65
75
|
**Usage Examples:**
|
|
66
76
|
```python
|
|
67
|
-
import
|
|
68
|
-
from src.solace_agent_mesh.common.utils.embeds.constants import EMBED_REGEX
|
|
69
|
-
|
|
70
|
-
text = "The price is «math:10 * 1.15 | .2f» and the ID is «uuid:new»."
|
|
77
|
+
from solace_agent_mesh.common.utils.embeds.constants import EMBED_REGEX
|
|
71
78
|
|
|
79
|
+
text = "Price: «math:10 * 1.15 | .2f» ID: «uuid:new»"
|
|
72
80
|
for match in EMBED_REGEX.finditer(text):
|
|
73
|
-
embed_type = match.group(1)
|
|
74
|
-
expression = match.group(2)
|
|
75
|
-
format_spec = match.group(3)
|
|
76
|
-
print(f"Type: {embed_type},
|
|
77
|
-
|
|
78
|
-
# Expected Output:
|
|
79
|
-
# Type: math, Expression: '10 * 1.15 ', Format: ' .2f'
|
|
80
|
-
# Type: uuid, Expression: 'new', Format: 'None'
|
|
81
|
+
embed_type = match.group(1) # "math" or "uuid"
|
|
82
|
+
expression = match.group(2) # "10 * 1.15 " or "new"
|
|
83
|
+
format_spec = match.group(3) # " .2f" or None
|
|
84
|
+
print(f"Type: {embed_type}, Expr: '{expression}', Format: '{format_spec}'")
|
|
81
85
|
```
|
|
82
86
|
|
|
83
|
-
---
|
|
84
87
|
### converter.py
|
|
85
|
-
**Purpose:**
|
|
88
|
+
**Purpose:** Provides data conversion between different formats and serialization to final string representations.
|
|
86
89
|
|
|
87
|
-
**Import:** `from
|
|
88
|
-
|
|
89
|
-
**Classes:**
|
|
90
|
-
- None
|
|
90
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds.converter import convert_data, serialize_data`
|
|
91
91
|
|
|
92
92
|
**Functions:**
|
|
93
|
-
- `convert_data(current_data: Any, current_format: Optional[DataFormat], target_format: DataFormat, log_id: str = "[Converter]", original_mime_type: Optional[str] = None) -> Tuple[Any, DataFormat, Optional[str]]
|
|
94
|
-
- `serialize_data(data: Any, data_format: Optional[DataFormat], target_string_format: Optional[str], original_mime_type: Optional[str], log_id: str = "[Serializer]") -> Tuple[str, Optional[str]]
|
|
95
|
-
|
|
96
|
-
**Constants/Variables:**
|
|
97
|
-
- None
|
|
93
|
+
- `convert_data(current_data: Any, current_format: Optional[DataFormat], target_format: DataFormat, log_id: str = "[Converter]", original_mime_type: Optional[str] = None) -> Tuple[Any, DataFormat, Optional[str]]` - Converts data between DataFormat types using MIME type hints
|
|
94
|
+
- `serialize_data(data: Any, data_format: Optional[DataFormat], target_string_format: Optional[str], original_mime_type: Optional[str], log_id: str = "[Serializer]") -> Tuple[str, Optional[str]]` - Serializes data to final string format (text, json, csv, datauri, or Python format specs)
|
|
98
95
|
|
|
99
96
|
**Usage Examples:**
|
|
100
97
|
```python
|
|
101
|
-
from
|
|
102
|
-
from
|
|
98
|
+
from solace_agent_mesh.common.utils.embeds.converter import convert_data, serialize_data
|
|
99
|
+
from solace_agent_mesh.common.utils.embeds.types import DataFormat
|
|
103
100
|
|
|
104
|
-
#
|
|
101
|
+
# Convert CSV bytes to list of dictionaries
|
|
105
102
|
csv_bytes = b"id,name\n1,Alice\n2,Bob"
|
|
106
|
-
|
|
103
|
+
list_data, new_format, err = convert_data(
|
|
107
104
|
current_data=csv_bytes,
|
|
108
105
|
current_format=DataFormat.BYTES,
|
|
109
106
|
target_format=DataFormat.LIST_OF_DICTS,
|
|
110
107
|
original_mime_type="text/csv"
|
|
111
108
|
)
|
|
112
|
-
if not err:
|
|
113
|
-
print(f"Converted data: {list_of_dicts}")
|
|
114
|
-
# Converted data: [{'id': '1', 'name': 'Alice'}, {'id': '2', 'name': 'Bob'}]
|
|
115
109
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
data=
|
|
110
|
+
# Serialize to pretty JSON
|
|
111
|
+
json_str, err = serialize_data(
|
|
112
|
+
data=list_data,
|
|
119
113
|
data_format=DataFormat.LIST_OF_DICTS,
|
|
120
114
|
target_string_format="json_pretty",
|
|
121
115
|
original_mime_type=None
|
|
122
116
|
)
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### evaluators.py
|
|
120
|
+
**Purpose:** Contains evaluation logic for simple embed types and the evaluator registry.
|
|
121
|
+
|
|
122
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds.evaluators import EMBED_EVALUATORS`
|
|
123
|
+
|
|
124
|
+
**Functions:**
|
|
125
|
+
- `_evaluate_math_embed(expression: str, context: Any, log_identifier: str, format_spec: Optional[str] = None) -> Tuple[str, Optional[str], int]` - Evaluates mathematical expressions using asteval
|
|
126
|
+
- `_evaluate_datetime_embed(expression: str, context: Any, log_identifier: str, format_spec: Optional[str] = None) -> Tuple[str, Optional[str], int]` - Formats current datetime
|
|
127
|
+
- `_evaluate_uuid_embed(expression: str, context: Any, log_identifier: str, format_spec: Optional[str] = None) -> Tuple[str, Optional[str], int]` - Generates UUID4 strings
|
|
128
|
+
- `_evaluate_artifact_meta_embed(expression: str, context: Dict[str, Any], log_identifier: str, format_spec: Optional[str] = None) -> Tuple[str, Optional[str], int]` - Loads and formats artifact metadata
|
|
129
|
+
- `_evaluate_artifact_content_embed(expression: str, context: Any, log_identifier: str, config: Optional[Dict] = None) -> Tuple[Optional[bytes], Optional[str], Optional[str]]` - Loads raw artifact content
|
|
130
|
+
|
|
131
|
+
**Constants/Variables:**
|
|
132
|
+
- `EMBED_EVALUATORS: Dict[str, Callable]` - Registry mapping embed types to evaluator functions
|
|
133
|
+
- `MATH_SAFE_SYMBOLS: Dict[str, Any]` - Safe mathematical functions and constants for math embeds
|
|
134
|
+
|
|
135
|
+
**Usage Examples:**
|
|
136
|
+
```python
|
|
137
|
+
from solace_agent_mesh.common.utils.embeds.evaluators import EMBED_EVALUATORS
|
|
138
|
+
|
|
139
|
+
# Math evaluation
|
|
140
|
+
result, error, size = EMBED_EVALUATORS["math"]("2 + 3 * 4", {}, "[Test]", ".2f")
|
|
141
|
+
# result: "14.00", error: None, size: 5
|
|
142
|
+
|
|
143
|
+
# DateTime formatting
|
|
144
|
+
result, error, size = EMBED_EVALUATORS["datetime"]("%Y-%m-%d", {}, "[Test]")
|
|
145
|
+
# result: "2024-01-15", error: None, size: 10
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### modifiers.py
|
|
149
|
+
**Purpose:** Implements data transformation functions that can be chained together in artifact_content embeds.
|
|
150
|
+
|
|
151
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds.modifiers import MODIFIER_DEFINITIONS, _parse_modifier_chain`
|
|
152
|
+
|
|
153
|
+
**Functions:**
|
|
154
|
+
- `_apply_jsonpath(current_data: Any, expression: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Applies JSONPath expressions to JSON data
|
|
155
|
+
- `_apply_select_cols(current_data: List[Dict], cols_str: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Selects specific columns from tabular data
|
|
156
|
+
- `_apply_filter_rows_eq(current_data: List[Dict], filter_spec: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Filters rows by column value equality
|
|
157
|
+
- `_apply_slice_rows(current_data: List[Dict], slice_spec: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Slices rows using Python slice notation
|
|
158
|
+
- `_apply_slice_lines(current_data: str, slice_spec: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Slices text lines
|
|
159
|
+
- `_apply_grep(current_data: str, pattern: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Filters lines matching regex pattern
|
|
160
|
+
- `_apply_head(current_data: str, n_str: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Returns first N lines
|
|
161
|
+
- `_apply_tail(current_data: str, n_str: str, mime_type: Optional[str], log_id: str) -> Tuple[Any, Optional[str], Optional[str]]` - Returns last N lines
|
|
162
|
+
- `_apply_template(current_data: Any, template_spec: str, mime_type: Optional[str], log_id: str, context: Any) -> Tuple[Any, Optional[str], Optional[str]]` - Applies Mustache templates from artifacts
|
|
163
|
+
- `_parse_modifier_chain(expression: str) -> Tuple[str, List[Tuple[str, str]], Optional[str]]` - Parses artifact_content expression into components
|
|
164
|
+
|
|
165
|
+
**Constants/Variables:**
|
|
166
|
+
- `MODIFIER_IMPLEMENTATIONS: Dict[str, Callable]` - Registry of modifier functions
|
|
167
|
+
- `MODIFIER_DEFINITIONS: Dict[str, Dict[str, Any]]` - Modifier metadata including accepted/produced formats
|
|
168
|
+
|
|
169
|
+
**Usage Examples:**
|
|
170
|
+
```python
|
|
171
|
+
from solace_agent_mesh.common.utils.embeds.modifiers import _parse_modifier_chain
|
|
172
|
+
|
|
173
|
+
# Parse a complex artifact_content expression
|
|
174
|
+
expression = "data.csv:1 >>> select_cols:name,age >>> filter_rows_eq:age:25 >>> format:json"
|
|
175
|
+
artifact_spec, modifiers, output_format = _parse_modifier_chain(expression)
|
|
176
|
+
# artifact_spec: "data.csv:1"
|
|
177
|
+
# modifiers: [("select_cols", "name,age"), ("filter_rows_eq", "age:25")]
|
|
178
|
+
# output_format: "json"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### resolver.py
|
|
182
|
+
**Purpose:** Core orchestration engine that handles the complete embed resolution process including modifier chains and recursion.
|
|
183
|
+
|
|
184
|
+
**Import:** `from solace_agent_mesh.common.utils.embeds.resolver import resolve_embeds_in_string, evaluate_embed`
|
|
185
|
+
|
|
186
|
+
**Functions:**
|
|
187
|
+
- `resolve_embeds_in_string(text: str, context: Any, resolver_func: Callable, types_to_resolve: Set[str], log_identifier: str = "[EmbedUtil]", config: Optional[Dict[str, Any]] = None) -> Tuple[str, int, List[Tuple[int, Any]]]` - Single-pass embed resolution with buffering support
|
|
188
|
+
- `resolve_embeds_recursively_in_string(text: str, context: Any, resolver_func: Callable, types_to_resolve: Set[str], log_identifier: str, config: Optional[Dict], max_depth: int, current_depth: int = 0, visited_artifacts: Optional[Set[Tuple[str, int]]] = None, accumulated_size: int = 0, max_total_size: int = -1) -> str` - Recursive embed resolution with safety limits
|
|
189
|
+
- `evaluate_embed(embed_type: str, expression: str, format_spec: Optional[str], context: Dict[str, Any], log_identifier: str, config: Optional[Dict] = None, current_depth: int = 0, visited_artifacts: Optional[Set[Tuple[str, int]]] = None) -> Union[Tuple[str, Optional[str], int], Tuple[None, str, Any]]` - Main embed evaluation dispatcher
|
|
190
|
+
|
|
191
|
+
**Usage Examples:**
|
|
192
|
+
```python
|
|
193
|
+
from solace_agent_mesh.common.utils.embeds.resolver import resolve_embeds_in_string, evaluate_embed
|
|
194
|
+
|
|
195
|
+
# Single-pass resolution
|
|
196
|
+
text = "Result: «math:2+3» and «uuid:new»"
|
|
197
|
+
context = {"artifact_service": service, "session_context": session_ctx}
|
|
198
|
+
|
|
199
|
+
resolved_text, processed_index, signals = await resolve_embeds_in_string(
|
|
200
|
+
text=text,
|
|
201
|
+
context=context,
|
|
202
|
+
resolver_func=evaluate_embed,
|
|
203
|
+
types_to_resolve={"math", "uuid"},
|
|
204
|
+
log_identifier="[MyApp]",
|
|
205
|
+
config={}
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# Complex artifact content with modifiers
|
|
209
|
+
result, error, size = await evaluate_embed(
|
|
210
|
+
embed_type="artifact_content",
|
|
211
|
+
expression="sales.csv >>> select_cols:product,revenue >>> format:json",
|
|
212
|
+
format_spec=None,
|
|
213
|
+
context=context,
|
|
214
|
+
log_identifier="[Sales]"
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### types.py
|
|
219
|
+
|
|
220
|
+
# content_hash: cbca48790a6e817c5bf49ddd8212cbbc663e920e9dd4dbece95bcf57d79c1837
|