aip-agents-binary 0.5.20__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.
- aip_agents/__init__.py +65 -0
- aip_agents/a2a/__init__.py +19 -0
- aip_agents/a2a/server/__init__.py +10 -0
- aip_agents/a2a/server/base_executor.py +1086 -0
- aip_agents/a2a/server/google_adk_executor.py +198 -0
- aip_agents/a2a/server/langflow_executor.py +180 -0
- aip_agents/a2a/server/langgraph_executor.py +270 -0
- aip_agents/a2a/types.py +232 -0
- aip_agents/agent/__init__.py +27 -0
- aip_agents/agent/base_agent.py +970 -0
- aip_agents/agent/base_langgraph_agent.py +2942 -0
- aip_agents/agent/google_adk_agent.py +926 -0
- aip_agents/agent/google_adk_constants.py +6 -0
- aip_agents/agent/hitl/__init__.py +24 -0
- aip_agents/agent/hitl/config.py +28 -0
- aip_agents/agent/hitl/langgraph_hitl_mixin.py +515 -0
- aip_agents/agent/hitl/manager.py +532 -0
- aip_agents/agent/hitl/models.py +18 -0
- aip_agents/agent/hitl/prompt/__init__.py +9 -0
- aip_agents/agent/hitl/prompt/base.py +42 -0
- aip_agents/agent/hitl/prompt/deferred.py +73 -0
- aip_agents/agent/hitl/registry.py +149 -0
- aip_agents/agent/interface.py +138 -0
- aip_agents/agent/interfaces.py +65 -0
- aip_agents/agent/langflow_agent.py +464 -0
- aip_agents/agent/langgraph_memory_enhancer_agent.py +433 -0
- aip_agents/agent/langgraph_react_agent.py +2514 -0
- aip_agents/agent/system_instruction_context.py +34 -0
- aip_agents/clients/__init__.py +10 -0
- aip_agents/clients/langflow/__init__.py +10 -0
- aip_agents/clients/langflow/client.py +477 -0
- aip_agents/clients/langflow/types.py +18 -0
- aip_agents/constants.py +23 -0
- aip_agents/credentials/manager.py +132 -0
- aip_agents/examples/__init__.py +5 -0
- aip_agents/examples/compare_streaming_client.py +783 -0
- aip_agents/examples/compare_streaming_server.py +142 -0
- aip_agents/examples/demo_memory_recall.py +401 -0
- aip_agents/examples/hello_world_a2a_google_adk_client.py +49 -0
- aip_agents/examples/hello_world_a2a_google_adk_client_agent.py +48 -0
- aip_agents/examples/hello_world_a2a_google_adk_client_streaming.py +60 -0
- aip_agents/examples/hello_world_a2a_google_adk_server.py +79 -0
- aip_agents/examples/hello_world_a2a_langchain_client.py +39 -0
- aip_agents/examples/hello_world_a2a_langchain_client_agent.py +39 -0
- aip_agents/examples/hello_world_a2a_langchain_client_lm_invoker.py +37 -0
- aip_agents/examples/hello_world_a2a_langchain_client_streaming.py +41 -0
- aip_agents/examples/hello_world_a2a_langchain_reference_client_streaming.py +60 -0
- aip_agents/examples/hello_world_a2a_langchain_reference_server.py +105 -0
- aip_agents/examples/hello_world_a2a_langchain_server.py +79 -0
- aip_agents/examples/hello_world_a2a_langchain_server_lm_invoker.py +78 -0
- aip_agents/examples/hello_world_a2a_langflow_client.py +83 -0
- aip_agents/examples/hello_world_a2a_langflow_server.py +82 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client.py +73 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_client_streaming.py +76 -0
- aip_agents/examples/hello_world_a2a_langgraph_artifact_server.py +92 -0
- aip_agents/examples/hello_world_a2a_langgraph_client.py +54 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_agent.py +54 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_agent_lm_invoker.py +32 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming.py +50 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_lm_invoker.py +44 -0
- aip_agents/examples/hello_world_a2a_langgraph_client_streaming_tool_streaming.py +92 -0
- aip_agents/examples/hello_world_a2a_langgraph_server.py +84 -0
- aip_agents/examples/hello_world_a2a_langgraph_server_lm_invoker.py +79 -0
- aip_agents/examples/hello_world_a2a_langgraph_server_tool_streaming.py +132 -0
- aip_agents/examples/hello_world_a2a_mcp_langgraph.py +196 -0
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_client.py +244 -0
- aip_agents/examples/hello_world_a2a_three_level_agent_hierarchy_server.py +251 -0
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_client.py +57 -0
- aip_agents/examples/hello_world_a2a_with_metadata_langchain_server_lm_invoker.py +80 -0
- aip_agents/examples/hello_world_google_adk.py +41 -0
- aip_agents/examples/hello_world_google_adk_mcp_http.py +34 -0
- aip_agents/examples/hello_world_google_adk_mcp_http_stream.py +40 -0
- aip_agents/examples/hello_world_google_adk_mcp_sse.py +44 -0
- aip_agents/examples/hello_world_google_adk_mcp_sse_stream.py +48 -0
- aip_agents/examples/hello_world_google_adk_mcp_stdio.py +44 -0
- aip_agents/examples/hello_world_google_adk_mcp_stdio_stream.py +48 -0
- aip_agents/examples/hello_world_google_adk_stream.py +44 -0
- aip_agents/examples/hello_world_langchain.py +28 -0
- aip_agents/examples/hello_world_langchain_lm_invoker.py +15 -0
- aip_agents/examples/hello_world_langchain_mcp_http.py +34 -0
- aip_agents/examples/hello_world_langchain_mcp_http_interactive.py +130 -0
- aip_agents/examples/hello_world_langchain_mcp_http_stream.py +42 -0
- aip_agents/examples/hello_world_langchain_mcp_multi_server.py +155 -0
- aip_agents/examples/hello_world_langchain_mcp_sse.py +34 -0
- aip_agents/examples/hello_world_langchain_mcp_sse_stream.py +40 -0
- aip_agents/examples/hello_world_langchain_mcp_stdio.py +30 -0
- aip_agents/examples/hello_world_langchain_mcp_stdio_stream.py +41 -0
- aip_agents/examples/hello_world_langchain_stream.py +36 -0
- aip_agents/examples/hello_world_langchain_stream_lm_invoker.py +39 -0
- aip_agents/examples/hello_world_langflow_agent.py +163 -0
- aip_agents/examples/hello_world_langgraph.py +39 -0
- aip_agents/examples/hello_world_langgraph_bosa_twitter.py +41 -0
- aip_agents/examples/hello_world_langgraph_mcp_http.py +31 -0
- aip_agents/examples/hello_world_langgraph_mcp_http_stream.py +34 -0
- aip_agents/examples/hello_world_langgraph_mcp_sse.py +35 -0
- aip_agents/examples/hello_world_langgraph_mcp_sse_stream.py +50 -0
- aip_agents/examples/hello_world_langgraph_mcp_stdio.py +35 -0
- aip_agents/examples/hello_world_langgraph_mcp_stdio_stream.py +50 -0
- aip_agents/examples/hello_world_langgraph_stream.py +43 -0
- aip_agents/examples/hello_world_langgraph_stream_lm_invoker.py +37 -0
- aip_agents/examples/hello_world_model_switch_cli.py +210 -0
- aip_agents/examples/hello_world_multi_agent_adk.py +75 -0
- aip_agents/examples/hello_world_multi_agent_langchain.py +54 -0
- aip_agents/examples/hello_world_multi_agent_langgraph.py +66 -0
- aip_agents/examples/hello_world_multi_agent_langgraph_lm_invoker.py +69 -0
- aip_agents/examples/hello_world_pii_logger.py +21 -0
- aip_agents/examples/hello_world_sentry.py +133 -0
- aip_agents/examples/hello_world_step_limits.py +273 -0
- aip_agents/examples/hello_world_stock_a2a_server.py +103 -0
- aip_agents/examples/hello_world_tool_output_client.py +46 -0
- aip_agents/examples/hello_world_tool_output_server.py +114 -0
- aip_agents/examples/hitl_demo.py +724 -0
- aip_agents/examples/mcp_configs/configs.py +63 -0
- aip_agents/examples/mcp_servers/common.py +76 -0
- aip_agents/examples/mcp_servers/mcp_name.py +29 -0
- aip_agents/examples/mcp_servers/mcp_server_http.py +19 -0
- aip_agents/examples/mcp_servers/mcp_server_sse.py +19 -0
- aip_agents/examples/mcp_servers/mcp_server_stdio.py +19 -0
- aip_agents/examples/mcp_servers/mcp_time.py +10 -0
- aip_agents/examples/pii_demo_langgraph_client.py +69 -0
- aip_agents/examples/pii_demo_langgraph_server.py +126 -0
- aip_agents/examples/pii_demo_multi_agent_client.py +80 -0
- aip_agents/examples/pii_demo_multi_agent_server.py +247 -0
- aip_agents/examples/todolist_planning_a2a_langchain_client.py +70 -0
- aip_agents/examples/todolist_planning_a2a_langgraph_server.py +88 -0
- aip_agents/examples/tools/__init__.py +27 -0
- aip_agents/examples/tools/adk_arithmetic_tools.py +36 -0
- aip_agents/examples/tools/adk_weather_tool.py +60 -0
- aip_agents/examples/tools/data_generator_tool.py +103 -0
- aip_agents/examples/tools/data_visualization_tool.py +312 -0
- aip_agents/examples/tools/image_artifact_tool.py +136 -0
- aip_agents/examples/tools/langchain_arithmetic_tools.py +26 -0
- aip_agents/examples/tools/langchain_currency_exchange_tool.py +88 -0
- aip_agents/examples/tools/langchain_graph_artifact_tool.py +172 -0
- aip_agents/examples/tools/langchain_weather_tool.py +48 -0
- aip_agents/examples/tools/langgraph_streaming_tool.py +130 -0
- aip_agents/examples/tools/mock_retrieval_tool.py +56 -0
- aip_agents/examples/tools/pii_demo_tools.py +189 -0
- aip_agents/examples/tools/random_chart_tool.py +142 -0
- aip_agents/examples/tools/serper_tool.py +202 -0
- aip_agents/examples/tools/stock_tools.py +82 -0
- aip_agents/examples/tools/table_generator_tool.py +167 -0
- aip_agents/examples/tools/time_tool.py +82 -0
- aip_agents/examples/tools/weather_forecast_tool.py +38 -0
- aip_agents/executor/agent_executor.py +473 -0
- aip_agents/executor/base.py +48 -0
- aip_agents/mcp/__init__.py +1 -0
- aip_agents/mcp/client/__init__.py +14 -0
- aip_agents/mcp/client/base_mcp_client.py +369 -0
- aip_agents/mcp/client/connection_manager.py +193 -0
- aip_agents/mcp/client/google_adk/__init__.py +11 -0
- aip_agents/mcp/client/google_adk/client.py +381 -0
- aip_agents/mcp/client/langchain/__init__.py +11 -0
- aip_agents/mcp/client/langchain/client.py +265 -0
- aip_agents/mcp/client/persistent_session.py +359 -0
- aip_agents/mcp/client/session_pool.py +351 -0
- aip_agents/mcp/client/transports.py +215 -0
- aip_agents/mcp/utils/__init__.py +7 -0
- aip_agents/mcp/utils/config_validator.py +139 -0
- aip_agents/memory/__init__.py +14 -0
- aip_agents/memory/adapters/__init__.py +10 -0
- aip_agents/memory/adapters/base_adapter.py +717 -0
- aip_agents/memory/adapters/mem0.py +84 -0
- aip_agents/memory/base.py +84 -0
- aip_agents/memory/constants.py +49 -0
- aip_agents/memory/factory.py +86 -0
- aip_agents/memory/guidance.py +20 -0
- aip_agents/memory/simple_memory.py +47 -0
- aip_agents/middleware/__init__.py +17 -0
- aip_agents/middleware/base.py +88 -0
- aip_agents/middleware/manager.py +128 -0
- aip_agents/middleware/todolist.py +274 -0
- aip_agents/schema/__init__.py +69 -0
- aip_agents/schema/a2a.py +56 -0
- aip_agents/schema/agent.py +111 -0
- aip_agents/schema/hitl.py +157 -0
- aip_agents/schema/langgraph.py +37 -0
- aip_agents/schema/model_id.py +97 -0
- aip_agents/schema/step_limit.py +108 -0
- aip_agents/schema/storage.py +40 -0
- aip_agents/sentry/__init__.py +11 -0
- aip_agents/sentry/sentry.py +151 -0
- aip_agents/storage/__init__.py +41 -0
- aip_agents/storage/base.py +85 -0
- aip_agents/storage/clients/__init__.py +12 -0
- aip_agents/storage/clients/minio_client.py +318 -0
- aip_agents/storage/config.py +62 -0
- aip_agents/storage/providers/__init__.py +15 -0
- aip_agents/storage/providers/base.py +106 -0
- aip_agents/storage/providers/memory.py +114 -0
- aip_agents/storage/providers/object_storage.py +214 -0
- aip_agents/tools/__init__.py +33 -0
- aip_agents/tools/bosa_tools.py +105 -0
- aip_agents/tools/browser_use/__init__.py +82 -0
- aip_agents/tools/browser_use/action_parser.py +103 -0
- aip_agents/tools/browser_use/browser_use_tool.py +1112 -0
- aip_agents/tools/browser_use/llm_config.py +120 -0
- aip_agents/tools/browser_use/minio_storage.py +198 -0
- aip_agents/tools/browser_use/schemas.py +119 -0
- aip_agents/tools/browser_use/session.py +76 -0
- aip_agents/tools/browser_use/session_errors.py +132 -0
- aip_agents/tools/browser_use/steel_session_recording.py +317 -0
- aip_agents/tools/browser_use/streaming.py +813 -0
- aip_agents/tools/browser_use/structured_data_parser.py +257 -0
- aip_agents/tools/browser_use/structured_data_recovery.py +204 -0
- aip_agents/tools/browser_use/types.py +78 -0
- aip_agents/tools/code_sandbox/__init__.py +26 -0
- aip_agents/tools/code_sandbox/constant.py +13 -0
- aip_agents/tools/code_sandbox/e2b_cloud_sandbox_extended.py +257 -0
- aip_agents/tools/code_sandbox/e2b_sandbox_tool.py +411 -0
- aip_agents/tools/constants.py +165 -0
- aip_agents/tools/document_loader/__init__.py +44 -0
- aip_agents/tools/document_loader/base_reader.py +302 -0
- aip_agents/tools/document_loader/docx_reader_tool.py +68 -0
- aip_agents/tools/document_loader/excel_reader_tool.py +171 -0
- aip_agents/tools/document_loader/pdf_reader_tool.py +79 -0
- aip_agents/tools/document_loader/pdf_splitter.py +169 -0
- aip_agents/tools/gl_connector/__init__.py +5 -0
- aip_agents/tools/gl_connector/tool.py +351 -0
- aip_agents/tools/memory_search/__init__.py +22 -0
- aip_agents/tools/memory_search/base.py +200 -0
- aip_agents/tools/memory_search/mem0.py +258 -0
- aip_agents/tools/memory_search/schema.py +48 -0
- aip_agents/tools/memory_search_tool.py +26 -0
- aip_agents/tools/time_tool.py +117 -0
- aip_agents/tools/tool_config_injector.py +300 -0
- aip_agents/tools/web_search/__init__.py +15 -0
- aip_agents/tools/web_search/serper_tool.py +187 -0
- aip_agents/types/__init__.py +70 -0
- aip_agents/types/a2a_events.py +13 -0
- aip_agents/utils/__init__.py +79 -0
- aip_agents/utils/a2a_connector.py +1757 -0
- aip_agents/utils/artifact_helpers.py +502 -0
- aip_agents/utils/constants.py +22 -0
- aip_agents/utils/datetime/__init__.py +34 -0
- aip_agents/utils/datetime/normalization.py +231 -0
- aip_agents/utils/datetime/timezone.py +206 -0
- aip_agents/utils/env_loader.py +27 -0
- aip_agents/utils/event_handler_registry.py +58 -0
- aip_agents/utils/file_prompt_utils.py +176 -0
- aip_agents/utils/final_response_builder.py +211 -0
- aip_agents/utils/formatter_llm_client.py +231 -0
- aip_agents/utils/langgraph/__init__.py +19 -0
- aip_agents/utils/langgraph/converter.py +128 -0
- aip_agents/utils/langgraph/tool_managers/__init__.py +15 -0
- aip_agents/utils/langgraph/tool_managers/a2a_tool_manager.py +99 -0
- aip_agents/utils/langgraph/tool_managers/base_tool_manager.py +66 -0
- aip_agents/utils/langgraph/tool_managers/delegation_tool_manager.py +1071 -0
- aip_agents/utils/langgraph/tool_output_management.py +967 -0
- aip_agents/utils/logger.py +195 -0
- aip_agents/utils/metadata/__init__.py +27 -0
- aip_agents/utils/metadata/activity_metadata_helper.py +407 -0
- aip_agents/utils/metadata/activity_narrative/__init__.py +35 -0
- aip_agents/utils/metadata/activity_narrative/builder.py +817 -0
- aip_agents/utils/metadata/activity_narrative/constants.py +51 -0
- aip_agents/utils/metadata/activity_narrative/context.py +49 -0
- aip_agents/utils/metadata/activity_narrative/formatters.py +230 -0
- aip_agents/utils/metadata/activity_narrative/utils.py +35 -0
- aip_agents/utils/metadata/schemas/__init__.py +16 -0
- aip_agents/utils/metadata/schemas/activity_schema.py +29 -0
- aip_agents/utils/metadata/schemas/thinking_schema.py +31 -0
- aip_agents/utils/metadata/thinking_metadata_helper.py +38 -0
- aip_agents/utils/metadata_helper.py +358 -0
- aip_agents/utils/name_preprocessor/__init__.py +17 -0
- aip_agents/utils/name_preprocessor/base_name_preprocessor.py +73 -0
- aip_agents/utils/name_preprocessor/google_name_preprocessor.py +100 -0
- aip_agents/utils/name_preprocessor/name_preprocessor.py +87 -0
- aip_agents/utils/name_preprocessor/openai_name_preprocessor.py +48 -0
- aip_agents/utils/pii/__init__.py +25 -0
- aip_agents/utils/pii/pii_handler.py +397 -0
- aip_agents/utils/pii/pii_helper.py +207 -0
- aip_agents/utils/pii/uuid_deanonymizer_mapping.py +195 -0
- aip_agents/utils/reference_helper.py +273 -0
- aip_agents/utils/sse_chunk_transformer.py +831 -0
- aip_agents/utils/step_limit_manager.py +265 -0
- aip_agents/utils/token_usage_helper.py +156 -0
- aip_agents_binary-0.5.20.dist-info/METADATA +681 -0
- aip_agents_binary-0.5.20.dist-info/RECORD +280 -0
- aip_agents_binary-0.5.20.dist-info/WHEEL +5 -0
- aip_agents_binary-0.5.20.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Configuration for MCP servers."""
|
|
2
|
+
|
|
3
|
+
mcp_config_sse = {
|
|
4
|
+
"playwright_tools": {
|
|
5
|
+
"url": "http://localhost:8931/sse",
|
|
6
|
+
"transport": "sse",
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
mcp_config_stdio = {
|
|
12
|
+
"weather_tools": {
|
|
13
|
+
"command": "python",
|
|
14
|
+
"args": ["aip_agents/examples/mcp_servers/mcp_server_stdio.py"],
|
|
15
|
+
"transport": "stdio",
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
mcp_config_http = {
|
|
20
|
+
"playwright_tools": {
|
|
21
|
+
"url": "http://localhost:8931/mcp",
|
|
22
|
+
"transport": "http",
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
mcp_multi_server = {
|
|
28
|
+
"sse_secretmsg": {
|
|
29
|
+
"url": "http://localhost:8123/sse",
|
|
30
|
+
"transport": "sse",
|
|
31
|
+
},
|
|
32
|
+
"stdio_time": {
|
|
33
|
+
"command": "python",
|
|
34
|
+
"args": ["aip_agents/examples/mcp_servers/mcp_time.py"],
|
|
35
|
+
"transport": "stdio",
|
|
36
|
+
},
|
|
37
|
+
"http_playwright_tools": {
|
|
38
|
+
"url": "http://localhost:8931/mcp",
|
|
39
|
+
"transport": "http",
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mcp_tool_whitelisting_demo = {
|
|
44
|
+
# STDIO server - allow only get_current_time (whitelist approach)
|
|
45
|
+
"stdio_time": {
|
|
46
|
+
"command": "python",
|
|
47
|
+
"args": ["aip_agents/examples/mcp_servers/mcp_server_stdio.py"],
|
|
48
|
+
"transport": "stdio",
|
|
49
|
+
"allowed_tools": ["get_current_time"],
|
|
50
|
+
},
|
|
51
|
+
# SSE server - allow only get_random_quote (whitelist approach)
|
|
52
|
+
"sse_quotes": {
|
|
53
|
+
"url": "http://localhost:8123/sse",
|
|
54
|
+
"transport": "sse",
|
|
55
|
+
"allowed_tools": ["get_random_quote"],
|
|
56
|
+
},
|
|
57
|
+
# HTTP server - allow only get_random_fact (whitelist approach)
|
|
58
|
+
"http_facts": {
|
|
59
|
+
"url": "http://localhost:8931/mcp",
|
|
60
|
+
"transport": "streamable-http",
|
|
61
|
+
"allowed_tools": ["get_random_fact"],
|
|
62
|
+
},
|
|
63
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Common reusable tool functions for MCP server examples."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import random
|
|
5
|
+
import uuid
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
# ===== Random Selection Tools =====
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_random_item_from_list(items: list[str]) -> str:
|
|
12
|
+
"""Return a random item from the given list."""
|
|
13
|
+
return random.choice(items)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_random_fact() -> str:
|
|
17
|
+
"""Return a random fun fact."""
|
|
18
|
+
facts = [
|
|
19
|
+
"Honey never spoils. Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly edible!",
|
|
20
|
+
"A group of flamingos is called a 'flamboyance'.",
|
|
21
|
+
"The shortest war in history was between Britain and Zanzibar in 1896. Zanzibar surrendered after 38 minutes.",
|
|
22
|
+
"There are more stars in the universe than grains of sand on all of Earth's beaches.",
|
|
23
|
+
"A banana is technically a berry, but a strawberry is not.",
|
|
24
|
+
]
|
|
25
|
+
return get_random_item_from_list(facts)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_random_quote() -> str:
|
|
29
|
+
"""Return a random inspirational quote."""
|
|
30
|
+
quotes = [
|
|
31
|
+
"The only way to do great work is to love what you do. - Steve Jobs",
|
|
32
|
+
"Innovation distinguishes between a leader and a follower. - Steve Jobs",
|
|
33
|
+
"Life is what happens when you're busy making other plans. - John Lennon",
|
|
34
|
+
"The future belongs to those who believe in the beauty of their dreams. - Eleanor Roosevelt",
|
|
35
|
+
"It is during our darkest moments that we must focus to see the light. - Aristotle",
|
|
36
|
+
]
|
|
37
|
+
return get_random_item_from_list(quotes)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def random_name_generator(name_list: list[str]) -> str:
|
|
41
|
+
"""Generate random name from the provided list."""
|
|
42
|
+
return get_random_item_from_list(name_list)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# ===== Time & UUID Tools =====
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_current_time() -> str:
|
|
49
|
+
"""Return the current time with format YYYY-MM-DD HH:MM:SS."""
|
|
50
|
+
return f"Current time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def generate_uuid() -> str:
|
|
54
|
+
"""Generate a random UUID."""
|
|
55
|
+
return f"Generated UUID: {uuid.uuid4()}"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# ===== Text Utilities =====
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def convert_to_base64(text: str) -> str:
|
|
62
|
+
"""Convert text to base64 representation."""
|
|
63
|
+
try:
|
|
64
|
+
encoded = base64.b64encode(text.encode()).decode()
|
|
65
|
+
return f"Base64: {encoded}"
|
|
66
|
+
except Exception as e:
|
|
67
|
+
return f"Error converting to base64: {str(e)}"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def word_count(text: str) -> str:
|
|
71
|
+
"""Count words in the given text."""
|
|
72
|
+
if not text.strip():
|
|
73
|
+
return "Word count: 0 (empty text)"
|
|
74
|
+
|
|
75
|
+
words = text.split()
|
|
76
|
+
return f"Word count: {len(words)} words"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Random Name Generator MCP Tool by SSE."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
from aip_agents.examples.mcp_servers.common import get_random_item_from_list
|
|
6
|
+
|
|
7
|
+
name_list = [
|
|
8
|
+
"Pedri",
|
|
9
|
+
"Joan Garcia",
|
|
10
|
+
"De Jong",
|
|
11
|
+
"Curbasi",
|
|
12
|
+
"Yamal",
|
|
13
|
+
"Kounde",
|
|
14
|
+
"Balde",
|
|
15
|
+
"Raphina",
|
|
16
|
+
"Fermin Lopez",
|
|
17
|
+
"Gavi",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def random_name_generator() -> str:
|
|
22
|
+
"""Generate random name."""
|
|
23
|
+
return get_random_item_from_list(name_list)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
mcp = FastMCP("Random Name Generator", port=8123)
|
|
28
|
+
mcp.add_tool(random_name_generator, name="random_name_generator")
|
|
29
|
+
mcp.run(transport="sse")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Weather Forecast & Trivia Tools MCP by Streamable HTTP with multiple tools."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
from aip_agents.examples.mcp_servers.common import convert_to_base64, get_random_fact
|
|
6
|
+
from aip_agents.examples.tools.weather_forecast_tool import get_weather_forecast
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
mcp = FastMCP("Weather-Trivia HTTP Server", port=8931)
|
|
10
|
+
mcp.add_tool(get_weather_forecast, name="get_weather_forecast")
|
|
11
|
+
mcp.add_tool(get_random_fact, name="get_random_fact")
|
|
12
|
+
mcp.add_tool(convert_to_base64, name="convert_to_base64")
|
|
13
|
+
|
|
14
|
+
print("Starting HTTP MCP Server with 3 tools:")
|
|
15
|
+
print("- get_weather_forecast")
|
|
16
|
+
print("- get_random_fact")
|
|
17
|
+
print("- convert_to_base64")
|
|
18
|
+
|
|
19
|
+
mcp.run(transport="streamable-http")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Weather Forecast & Text Tools MCP by SSE with multiple tools."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
from aip_agents.examples.mcp_servers.common import get_random_quote, word_count
|
|
6
|
+
from aip_agents.examples.tools.weather_forecast_tool import get_weather_forecast
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
mcp = FastMCP("Weather-Text SSE Server", port=8123)
|
|
10
|
+
mcp.add_tool(get_weather_forecast, name="get_weather_forecast")
|
|
11
|
+
mcp.add_tool(get_random_quote, name="get_random_quote")
|
|
12
|
+
mcp.add_tool(word_count, name="word_count")
|
|
13
|
+
|
|
14
|
+
print("Starting SSE MCP Server with 3 tools:")
|
|
15
|
+
print("- get_weather_forecast")
|
|
16
|
+
print("- get_random_quote")
|
|
17
|
+
print("- word_count")
|
|
18
|
+
|
|
19
|
+
mcp.run(transport="sse")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Weather Forecast & Time Tools MCP by STDIO with multiple tools."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
from aip_agents.examples.mcp_servers.common import generate_uuid, get_current_time
|
|
6
|
+
from aip_agents.examples.tools.weather_forecast_tool import get_weather_forecast
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
mcp = FastMCP("Weather-Time STDIO Server")
|
|
10
|
+
mcp.add_tool(get_weather_forecast, name="get_weather_forecast")
|
|
11
|
+
mcp.add_tool(get_current_time, name="get_current_time")
|
|
12
|
+
mcp.add_tool(generate_uuid, name="generate_uuid")
|
|
13
|
+
|
|
14
|
+
print("Starting STDIO MCP Server with 3 tools:")
|
|
15
|
+
print("- get_weather_forecast")
|
|
16
|
+
print("- get_current_time")
|
|
17
|
+
print("- generate_uuid")
|
|
18
|
+
|
|
19
|
+
mcp.run(transport="stdio")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Time MCP Tool STDIO."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
from aip_agents.examples.mcp_servers.common import get_current_time as time_tool
|
|
6
|
+
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
mcp = FastMCP("Time")
|
|
9
|
+
mcp.add_tool(time_tool, name="time")
|
|
10
|
+
mcp.run(transport="stdio")
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Streaming PII demo client - inspect streaming chunks in real-time.
|
|
2
|
+
|
|
3
|
+
To run:
|
|
4
|
+
1. Start server:
|
|
5
|
+
export NER_API_URL=http://localhost:8080
|
|
6
|
+
export NER_API_KEY=your-api-key
|
|
7
|
+
python examples/pii_demo_langgraph_server.py
|
|
8
|
+
|
|
9
|
+
2. Run client:
|
|
10
|
+
python examples/pii_demo_langgraph_client.py
|
|
11
|
+
|
|
12
|
+
Authors:
|
|
13
|
+
Fachriza Adhiatma (fachriza.d.adhiatma@gdplabs.id)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
from pprint import pprint
|
|
18
|
+
|
|
19
|
+
from langchain_openai import ChatOpenAI
|
|
20
|
+
|
|
21
|
+
from aip_agents.agent import LangChainAgent
|
|
22
|
+
from aip_agents.schema.agent import A2AClientConfig
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
async def main():
|
|
26
|
+
"""Stream queries and inspect chunks with PII handling."""
|
|
27
|
+
# Setup
|
|
28
|
+
llm = ChatOpenAI(model="gpt-4.1", streaming=True)
|
|
29
|
+
client_agent = LangChainAgent(
|
|
30
|
+
name="PIIDemoClient",
|
|
31
|
+
instruction="""You are a helpful assistant. When asked for customer, employee, or user info, delegate to the PII demo agent.
|
|
32
|
+
You will receive output from tool in masked version, just write the response naturally without revealing or changing the masked values.""",
|
|
33
|
+
model=llm,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Discover agents
|
|
37
|
+
print("š Discovering agents...\n")
|
|
38
|
+
config = A2AClientConfig(discovery_urls=["http://localhost:8002"])
|
|
39
|
+
agent_cards = client_agent.discover_agents(config)
|
|
40
|
+
client_agent.register_a2a_agents(agent_cards)
|
|
41
|
+
print(f"ā
Found: {agent_cards[0].name}\n")
|
|
42
|
+
|
|
43
|
+
# Example queries
|
|
44
|
+
queries = [
|
|
45
|
+
"Can you get me information about customers <PERSON_1> and <PERSON_2>?",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
# Stream each query
|
|
49
|
+
for i, query in enumerate(queries, 1):
|
|
50
|
+
print(f"\n{'=' * 80}")
|
|
51
|
+
print(f"Query {i}: {query}")
|
|
52
|
+
print("=" * 80)
|
|
53
|
+
print("\nš” Streaming chunks:\n")
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
async for chunk in client_agent.astream_to_agent(
|
|
57
|
+
agent_card=agent_cards[0],
|
|
58
|
+
message=query,
|
|
59
|
+
pii_mapping={"<PERSON_1>": "C001", "<PERSON_2>": "C002"},
|
|
60
|
+
):
|
|
61
|
+
pprint(chunk)
|
|
62
|
+
print("-" * 50)
|
|
63
|
+
|
|
64
|
+
except Exception as e:
|
|
65
|
+
print(f"\nā Error: {e}")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""Example A2A server demonstrating PII handling in LangGraph agents.
|
|
2
|
+
|
|
3
|
+
This server instantiates a LangGraph ReAct agent with tools that return personally
|
|
4
|
+
identifiable information (PII). The agent demonstrates automatic PII anonymization
|
|
5
|
+
and deanonymization during parallel tool execution.
|
|
6
|
+
|
|
7
|
+
Features demonstrated:
|
|
8
|
+
- Automatic PII detection and anonymization in tool outputs
|
|
9
|
+
- Deanonymization of PII for tool input arguments
|
|
10
|
+
- Collision detection and resolution in parallel tool execution
|
|
11
|
+
- Hybrid tag strategy (sequential tags preserved, UUID tags for collisions)
|
|
12
|
+
|
|
13
|
+
To run this server:
|
|
14
|
+
export NER_API_URL=http://localhost:8080
|
|
15
|
+
export NER_API_KEY=your-api-key
|
|
16
|
+
python examples/pii_demo_langgraph_server.py
|
|
17
|
+
|
|
18
|
+
It will listen on http://localhost:8002 by default.
|
|
19
|
+
|
|
20
|
+
Authors:
|
|
21
|
+
Fachriza Adhiatma (fachriza.d.adhiatma@gdplabs.id)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import click
|
|
25
|
+
import uvicorn
|
|
26
|
+
from a2a.types import AgentCapabilities, AgentCard, AgentSkill
|
|
27
|
+
from dotenv import load_dotenv
|
|
28
|
+
|
|
29
|
+
from aip_agents.agent import LangChainAgent
|
|
30
|
+
from aip_agents.examples.tools.pii_demo_tools import (
|
|
31
|
+
get_customer_info,
|
|
32
|
+
get_employee_data,
|
|
33
|
+
get_user_profile,
|
|
34
|
+
)
|
|
35
|
+
from aip_agents.utils.logger import LoggerManager
|
|
36
|
+
|
|
37
|
+
load_dotenv()
|
|
38
|
+
|
|
39
|
+
logger = LoggerManager().get_logger(__name__)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
SERVER_AGENT_NAME = "PIIDemoAgentLangGraph"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@click.command()
|
|
46
|
+
@click.option("--host", "host", default="localhost", help="Host to bind the server to.")
|
|
47
|
+
@click.option("--port", "port", default=8002, help="Port to bind the server to.")
|
|
48
|
+
def main(host: str, port: int):
|
|
49
|
+
"""Runs the PII Demo LangGraph A2A server.
|
|
50
|
+
|
|
51
|
+
This server demonstrates PII handling capabilities including:
|
|
52
|
+
- Automatic anonymization of sensitive data in tool outputs
|
|
53
|
+
- Deanonymization of PII for tool inputs
|
|
54
|
+
- Collision detection and resolution in parallel tool execution
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
host (str): Host to bind the server to.
|
|
58
|
+
port (int): Port to bind the server to.
|
|
59
|
+
"""
|
|
60
|
+
logger.info(f"Starting {SERVER_AGENT_NAME} on http://{host}:{port}")
|
|
61
|
+
logger.info("PII handling is enabled. Sensitive data will be automatically anonymized.")
|
|
62
|
+
|
|
63
|
+
agent_card = AgentCard(
|
|
64
|
+
name=SERVER_AGENT_NAME,
|
|
65
|
+
description="A LangGraph ReAct agent demonstrating PII handling with automatic anonymization and deanonymization",
|
|
66
|
+
url=f"http://{host}:{port}",
|
|
67
|
+
version="1.0.0",
|
|
68
|
+
defaultInputModes=["text"],
|
|
69
|
+
defaultOutputModes=["text"],
|
|
70
|
+
capabilities=AgentCapabilities(streaming=True),
|
|
71
|
+
skills=[
|
|
72
|
+
AgentSkill(
|
|
73
|
+
id="customer_info",
|
|
74
|
+
name="Get Customer Information",
|
|
75
|
+
description="Retrieves customer information including email and phone number",
|
|
76
|
+
examples=["Get customer info for C001", "What is the email for customer C002?"],
|
|
77
|
+
tags=["customer", "pii"],
|
|
78
|
+
),
|
|
79
|
+
AgentSkill(
|
|
80
|
+
id="employee_data",
|
|
81
|
+
name="Get Employee Data",
|
|
82
|
+
description="Retrieves employee data including name, email, and salary",
|
|
83
|
+
examples=["Get employee data for E001", "What is the salary for employee E002?"],
|
|
84
|
+
tags=["employee", "pii"],
|
|
85
|
+
),
|
|
86
|
+
AgentSkill(
|
|
87
|
+
id="user_profile",
|
|
88
|
+
name="Get User Profile",
|
|
89
|
+
description="Retrieves user profile information with personal details",
|
|
90
|
+
examples=["Get user profile for U001", "What is the email for user U002?"],
|
|
91
|
+
tags=["user", "pii"],
|
|
92
|
+
),
|
|
93
|
+
],
|
|
94
|
+
tags=["pii", "demo", "langgraph"],
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
langgraph_agent = LangChainAgent(
|
|
98
|
+
name=SERVER_AGENT_NAME,
|
|
99
|
+
instruction="""You are a helpful assistant that can retrieve customer, employee, and user information.
|
|
100
|
+
|
|
101
|
+
You have access to three tools:
|
|
102
|
+
1. get_customer_info: Retrieves customer information (email, phone, address)
|
|
103
|
+
2. get_employee_data: Retrieves employee data (email, phone, salary, department)
|
|
104
|
+
3. get_user_profile: Retrieves user profile information (email, phone, date of birth, city)
|
|
105
|
+
|
|
106
|
+
When users ask for information, use the appropriate tool to retrieve the data.
|
|
107
|
+
The system will automatically handle PII anonymization and deanonymization.
|
|
108
|
+
|
|
109
|
+
You will receive output from tool in masked version,
|
|
110
|
+
just write the response as it is without revealing or changing the masked values.
|
|
111
|
+
|
|
112
|
+
Always be helpful and provide the requested information clearly.""",
|
|
113
|
+
model="openai/gpt-4.1",
|
|
114
|
+
tools=[get_customer_info, get_employee_data, get_user_profile],
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
app = langgraph_agent.to_a2a(
|
|
118
|
+
agent_card=agent_card,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
logger.info("A2A application configured. Starting Uvicorn server...")
|
|
122
|
+
uvicorn.run(app, host=host, port=port)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__ == "__main__":
|
|
126
|
+
main()
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Multi-Agent PII Demo Client - Tests PII handling across agent hierarchy.
|
|
2
|
+
|
|
3
|
+
This client demonstrates connecting to and using a hierarchical agent system
|
|
4
|
+
that manages PII across multiple specialist agents through A2A protocol.
|
|
5
|
+
|
|
6
|
+
To run this client:
|
|
7
|
+
1. First start the server:
|
|
8
|
+
export NER_API_URL=http://localhost:8080
|
|
9
|
+
export NER_API_KEY=your-api-key
|
|
10
|
+
python aip_agents/examples/pii_demo_multi_agent_server.py
|
|
11
|
+
|
|
12
|
+
2. Then run this client:
|
|
13
|
+
python aip_agents/examples/pii_demo_multi_agent_client.py
|
|
14
|
+
|
|
15
|
+
Authors:
|
|
16
|
+
Fachriza Adhiatma (fachriza.d.adhiatma@gdplabs.id)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import asyncio
|
|
20
|
+
from pprint import pprint
|
|
21
|
+
|
|
22
|
+
from dotenv import load_dotenv
|
|
23
|
+
from langchain_openai import ChatOpenAI
|
|
24
|
+
|
|
25
|
+
from aip_agents.agent import LangGraphAgent
|
|
26
|
+
from aip_agents.schema.agent import A2AClientConfig
|
|
27
|
+
|
|
28
|
+
load_dotenv()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def main():
|
|
32
|
+
"""Main function demonstrating the Multi-Agent PII Demo client."""
|
|
33
|
+
llm = ChatOpenAI(model="gpt-4.1", streaming=True)
|
|
34
|
+
|
|
35
|
+
# Create a simple client agent
|
|
36
|
+
client_agent = LangGraphAgent(
|
|
37
|
+
name="PIIMultiAgentTestClient",
|
|
38
|
+
instruction=(
|
|
39
|
+
"You are a test client that communicates with hierarchical agent systems via A2A. "
|
|
40
|
+
"You will receive responses with PII tags - present them as-is."
|
|
41
|
+
),
|
|
42
|
+
model=llm,
|
|
43
|
+
tools=[],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Discover the coordinator agent
|
|
47
|
+
print("š Discovering PIICoordinator agent...\n")
|
|
48
|
+
config = A2AClientConfig(discovery_urls=["http://localhost:8003"])
|
|
49
|
+
agent_cards = client_agent.discover_agents(config)
|
|
50
|
+
client_agent.register_a2a_agents(agent_cards)
|
|
51
|
+
print(f"ā
Found: {agent_cards[0].name}\n")
|
|
52
|
+
|
|
53
|
+
# Example queries demonstrating multi-agent PII handling
|
|
54
|
+
queries = [
|
|
55
|
+
"I need information about customer <PERSON_1> and employee E001",
|
|
56
|
+
"Find me information about customer <PERSON_1>, and then find information about employee E001, don't run tool in paralel",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
# Stream each query
|
|
60
|
+
for i, query in enumerate(queries, 1):
|
|
61
|
+
print(f"\n{'=' * 80}")
|
|
62
|
+
print(f"Query {i}: {query}")
|
|
63
|
+
print("=" * 80)
|
|
64
|
+
print("\nš” Streaming chunks:\n")
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
async for chunk in client_agent.astream_to_agent(
|
|
68
|
+
agent_card=agent_cards[0],
|
|
69
|
+
message=query,
|
|
70
|
+
pii_mapping={"<EMAIL_ADDRESS_1>": "john.smith@example.com", "<PERSON_1>": "C001"},
|
|
71
|
+
):
|
|
72
|
+
pprint(chunk)
|
|
73
|
+
print("-" * 50)
|
|
74
|
+
|
|
75
|
+
except Exception as e:
|
|
76
|
+
print(f"\nā Error: {e}")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
asyncio.run(main())
|