mail-swarms 1.3.2__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.
- mail/__init__.py +35 -0
- mail/api.py +1964 -0
- mail/cli.py +432 -0
- mail/client.py +1657 -0
- mail/config/__init__.py +8 -0
- mail/config/client.py +87 -0
- mail/config/server.py +165 -0
- mail/core/__init__.py +72 -0
- mail/core/actions.py +69 -0
- mail/core/agents.py +73 -0
- mail/core/message.py +366 -0
- mail/core/runtime.py +3537 -0
- mail/core/tasks.py +311 -0
- mail/core/tools.py +1206 -0
- mail/db/__init__.py +0 -0
- mail/db/init.py +182 -0
- mail/db/types.py +65 -0
- mail/db/utils.py +523 -0
- mail/examples/__init__.py +27 -0
- mail/examples/analyst_dummy/__init__.py +15 -0
- mail/examples/analyst_dummy/agent.py +136 -0
- mail/examples/analyst_dummy/prompts.py +44 -0
- mail/examples/consultant_dummy/__init__.py +15 -0
- mail/examples/consultant_dummy/agent.py +136 -0
- mail/examples/consultant_dummy/prompts.py +42 -0
- mail/examples/data_analysis/__init__.py +40 -0
- mail/examples/data_analysis/analyst/__init__.py +9 -0
- mail/examples/data_analysis/analyst/agent.py +67 -0
- mail/examples/data_analysis/analyst/prompts.py +53 -0
- mail/examples/data_analysis/processor/__init__.py +13 -0
- mail/examples/data_analysis/processor/actions.py +293 -0
- mail/examples/data_analysis/processor/agent.py +67 -0
- mail/examples/data_analysis/processor/prompts.py +48 -0
- mail/examples/data_analysis/reporter/__init__.py +10 -0
- mail/examples/data_analysis/reporter/actions.py +187 -0
- mail/examples/data_analysis/reporter/agent.py +67 -0
- mail/examples/data_analysis/reporter/prompts.py +49 -0
- mail/examples/data_analysis/statistics/__init__.py +18 -0
- mail/examples/data_analysis/statistics/actions.py +343 -0
- mail/examples/data_analysis/statistics/agent.py +67 -0
- mail/examples/data_analysis/statistics/prompts.py +60 -0
- mail/examples/mafia/__init__.py +0 -0
- mail/examples/mafia/game.py +1537 -0
- mail/examples/mafia/narrator_tools.py +396 -0
- mail/examples/mafia/personas.py +240 -0
- mail/examples/mafia/prompts.py +489 -0
- mail/examples/mafia/roles.py +147 -0
- mail/examples/mafia/spec.md +350 -0
- mail/examples/math_dummy/__init__.py +23 -0
- mail/examples/math_dummy/actions.py +252 -0
- mail/examples/math_dummy/agent.py +136 -0
- mail/examples/math_dummy/prompts.py +46 -0
- mail/examples/math_dummy/types.py +5 -0
- mail/examples/research/__init__.py +39 -0
- mail/examples/research/researcher/__init__.py +9 -0
- mail/examples/research/researcher/agent.py +67 -0
- mail/examples/research/researcher/prompts.py +54 -0
- mail/examples/research/searcher/__init__.py +10 -0
- mail/examples/research/searcher/actions.py +324 -0
- mail/examples/research/searcher/agent.py +67 -0
- mail/examples/research/searcher/prompts.py +53 -0
- mail/examples/research/summarizer/__init__.py +18 -0
- mail/examples/research/summarizer/actions.py +255 -0
- mail/examples/research/summarizer/agent.py +67 -0
- mail/examples/research/summarizer/prompts.py +55 -0
- mail/examples/research/verifier/__init__.py +10 -0
- mail/examples/research/verifier/actions.py +337 -0
- mail/examples/research/verifier/agent.py +67 -0
- mail/examples/research/verifier/prompts.py +52 -0
- mail/examples/supervisor/__init__.py +11 -0
- mail/examples/supervisor/agent.py +4 -0
- mail/examples/supervisor/prompts.py +93 -0
- mail/examples/support/__init__.py +33 -0
- mail/examples/support/classifier/__init__.py +10 -0
- mail/examples/support/classifier/actions.py +307 -0
- mail/examples/support/classifier/agent.py +68 -0
- mail/examples/support/classifier/prompts.py +56 -0
- mail/examples/support/coordinator/__init__.py +9 -0
- mail/examples/support/coordinator/agent.py +67 -0
- mail/examples/support/coordinator/prompts.py +48 -0
- mail/examples/support/faq/__init__.py +10 -0
- mail/examples/support/faq/actions.py +182 -0
- mail/examples/support/faq/agent.py +67 -0
- mail/examples/support/faq/prompts.py +42 -0
- mail/examples/support/sentiment/__init__.py +15 -0
- mail/examples/support/sentiment/actions.py +341 -0
- mail/examples/support/sentiment/agent.py +67 -0
- mail/examples/support/sentiment/prompts.py +54 -0
- mail/examples/weather_dummy/__init__.py +23 -0
- mail/examples/weather_dummy/actions.py +75 -0
- mail/examples/weather_dummy/agent.py +136 -0
- mail/examples/weather_dummy/prompts.py +35 -0
- mail/examples/weather_dummy/types.py +5 -0
- mail/factories/__init__.py +27 -0
- mail/factories/action.py +223 -0
- mail/factories/base.py +1531 -0
- mail/factories/supervisor.py +241 -0
- mail/net/__init__.py +7 -0
- mail/net/registry.py +712 -0
- mail/net/router.py +728 -0
- mail/net/server_utils.py +114 -0
- mail/net/types.py +247 -0
- mail/server.py +1605 -0
- mail/stdlib/__init__.py +0 -0
- mail/stdlib/anthropic/__init__.py +0 -0
- mail/stdlib/fs/__init__.py +15 -0
- mail/stdlib/fs/actions.py +209 -0
- mail/stdlib/http/__init__.py +19 -0
- mail/stdlib/http/actions.py +333 -0
- mail/stdlib/interswarm/__init__.py +11 -0
- mail/stdlib/interswarm/actions.py +208 -0
- mail/stdlib/mcp/__init__.py +19 -0
- mail/stdlib/mcp/actions.py +294 -0
- mail/stdlib/openai/__init__.py +13 -0
- mail/stdlib/openai/agents.py +451 -0
- mail/summarizer.py +234 -0
- mail/swarms_json/__init__.py +27 -0
- mail/swarms_json/types.py +87 -0
- mail/swarms_json/utils.py +255 -0
- mail/url_scheme.py +51 -0
- mail/utils/__init__.py +53 -0
- mail/utils/auth.py +194 -0
- mail/utils/context.py +17 -0
- mail/utils/logger.py +73 -0
- mail/utils/openai.py +212 -0
- mail/utils/parsing.py +89 -0
- mail/utils/serialize.py +292 -0
- mail/utils/store.py +49 -0
- mail/utils/string_builder.py +119 -0
- mail/utils/version.py +20 -0
- mail_swarms-1.3.2.dist-info/METADATA +237 -0
- mail_swarms-1.3.2.dist-info/RECORD +137 -0
- mail_swarms-1.3.2.dist-info/WHEEL +4 -0
- mail_swarms-1.3.2.dist-info/entry_points.txt +2 -0
- mail_swarms-1.3.2.dist-info/licenses/LICENSE +202 -0
- mail_swarms-1.3.2.dist-info/licenses/NOTICE +10 -0
- mail_swarms-1.3.2.dist-info/licenses/THIRD_PARTY_NOTICES.md +12334 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
SYSPROMPT = """You are analyst@{swarm}, a specialist agent for research and data analysis.
|
|
2
|
+
|
|
3
|
+
# Your Role
|
|
4
|
+
Analyze information, research topics, interpret data, and provide detailed analytical reports. Focus on facts, trends, and evidence-based conclusions.
|
|
5
|
+
|
|
6
|
+
# Critical Rule: Responding
|
|
7
|
+
You CANNOT talk to users directly or call `task_complete`. You MUST use `send_response` to reply to the agent who contacted you.
|
|
8
|
+
- When you receive a request, note the sender address
|
|
9
|
+
- After completing your analysis, call `send_response(target=<sender>, subject="Re: ...", body=<your analysis>)`
|
|
10
|
+
- Your response body must contain ALL findings - the requestor cannot see your work otherwise
|
|
11
|
+
|
|
12
|
+
# Tools
|
|
13
|
+
|
|
14
|
+
## Communication
|
|
15
|
+
- `send_response(target, subject, body)`: Reply to the agent who requested analysis - THIS IS REQUIRED
|
|
16
|
+
- `send_request(target, subject, body)`: Ask another agent for additional data (if needed)
|
|
17
|
+
- `acknowledge_broadcast(note)`: Acknowledge a broadcast message
|
|
18
|
+
- `ignore_broadcast(reason)`: Ignore an irrelevant broadcast
|
|
19
|
+
|
|
20
|
+
# Workflow
|
|
21
|
+
|
|
22
|
+
1. Receive request from another agent (note the sender address in the message)
|
|
23
|
+
2. Analyze the question, data, or topic presented
|
|
24
|
+
3. Synthesize findings into a clear response
|
|
25
|
+
4. Call `send_response` to the original sender with your complete analysis
|
|
26
|
+
|
|
27
|
+
# Response Format
|
|
28
|
+
|
|
29
|
+
Structure your analysis clearly:
|
|
30
|
+
- Summary of findings (1-2 sentences)
|
|
31
|
+
- Key data points or observations
|
|
32
|
+
- Analysis and interpretation
|
|
33
|
+
- Conclusions or implications
|
|
34
|
+
- Limitations or areas of uncertainty
|
|
35
|
+
|
|
36
|
+
# Guidelines
|
|
37
|
+
|
|
38
|
+
- Ground analysis in available information
|
|
39
|
+
- Distinguish facts from inferences
|
|
40
|
+
- Quantify when possible (percentages, ranges, comparisons)
|
|
41
|
+
- Acknowledge limitations in data or analysis
|
|
42
|
+
- Match the requested format/length if specified
|
|
43
|
+
- Use "Re: <original subject>" as your response subject
|
|
44
|
+
- If you need more information to complete the analysis, specify what's needed"""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .agent import (
|
|
2
|
+
LiteLLMConsultantFunction,
|
|
3
|
+
consultant_agent_params,
|
|
4
|
+
factory_consultant_dummy,
|
|
5
|
+
)
|
|
6
|
+
from .prompts import (
|
|
7
|
+
SYSPROMPT as CONSULTANT_SYSPROMPT,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"factory_consultant_dummy",
|
|
12
|
+
"LiteLLMConsultantFunction",
|
|
13
|
+
"consultant_agent_params",
|
|
14
|
+
"CONSULTANT_SYSPROMPT",
|
|
15
|
+
]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Addison Kline
|
|
3
|
+
|
|
4
|
+
import warnings
|
|
5
|
+
from collections.abc import Awaitable
|
|
6
|
+
from typing import Any, Literal
|
|
7
|
+
|
|
8
|
+
from mail.core.agents import AgentOutput
|
|
9
|
+
from mail.factories import AgentFunction
|
|
10
|
+
from mail.factories.base import LiteLLMAgentFunction
|
|
11
|
+
|
|
12
|
+
consultant_agent_params = {
|
|
13
|
+
"llm": "openai/gpt-5-mini",
|
|
14
|
+
"system": "mail.examples.consultant_dummy.prompts:SYSPROMPT",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def factory_consultant_dummy(
|
|
19
|
+
# REQUIRED
|
|
20
|
+
# top-level params
|
|
21
|
+
comm_targets: list[str],
|
|
22
|
+
tools: list[dict[str, Any]],
|
|
23
|
+
# instance params
|
|
24
|
+
user_token: str,
|
|
25
|
+
# internal params
|
|
26
|
+
llm: str,
|
|
27
|
+
system: str,
|
|
28
|
+
# OPTIONAL
|
|
29
|
+
# top-level params
|
|
30
|
+
name: str = "consultant",
|
|
31
|
+
enable_entrypoint: bool = False,
|
|
32
|
+
enable_interswarm: bool = False,
|
|
33
|
+
can_complete_tasks: bool = False,
|
|
34
|
+
tool_format: Literal["completions", "responses"] = "responses",
|
|
35
|
+
exclude_tools: list[str] = [],
|
|
36
|
+
# instance params
|
|
37
|
+
# ...
|
|
38
|
+
# internal params
|
|
39
|
+
reasoning_effort: Literal["low", "medium", "high"] | None = None,
|
|
40
|
+
thinking_budget: int | None = None,
|
|
41
|
+
max_tokens: int | None = None,
|
|
42
|
+
memory: bool = True,
|
|
43
|
+
use_proxy: bool = True,
|
|
44
|
+
) -> AgentFunction:
|
|
45
|
+
warnings.warn(
|
|
46
|
+
"`mail.examples.consultant_dummy:factory_consultant_dummy` is deprecated and will be removed in a future version. "
|
|
47
|
+
"Use `mail.examples.consultant_dummy:LiteLLMConsultantFunction` instead.",
|
|
48
|
+
DeprecationWarning,
|
|
49
|
+
stacklevel=2,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
litellm_consultant = LiteLLMConsultantFunction(
|
|
53
|
+
name=name,
|
|
54
|
+
comm_targets=comm_targets,
|
|
55
|
+
tools=tools,
|
|
56
|
+
llm=llm,
|
|
57
|
+
system=system,
|
|
58
|
+
user_token=user_token,
|
|
59
|
+
enable_entrypoint=enable_entrypoint,
|
|
60
|
+
enable_interswarm=enable_interswarm,
|
|
61
|
+
can_complete_tasks=can_complete_tasks,
|
|
62
|
+
reasoning_effort=reasoning_effort,
|
|
63
|
+
thinking_budget=thinking_budget,
|
|
64
|
+
max_tokens=max_tokens,
|
|
65
|
+
memory=memory,
|
|
66
|
+
use_proxy=use_proxy,
|
|
67
|
+
tool_format=tool_format,
|
|
68
|
+
exclude_tools=exclude_tools,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
async def run(
|
|
72
|
+
messages: list[dict[str, Any]],
|
|
73
|
+
tool_choice: str | dict[str, str] = "required",
|
|
74
|
+
) -> AgentOutput:
|
|
75
|
+
"""
|
|
76
|
+
Execute the LiteLLM-based consultant agent function.
|
|
77
|
+
"""
|
|
78
|
+
return await litellm_consultant(messages, tool_choice)
|
|
79
|
+
|
|
80
|
+
return run
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class LiteLLMConsultantFunction(LiteLLMAgentFunction):
|
|
84
|
+
"""
|
|
85
|
+
Class that represents a LiteLLM-based consultant agent function.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def __init__(
|
|
89
|
+
self,
|
|
90
|
+
name: str,
|
|
91
|
+
comm_targets: list[str],
|
|
92
|
+
tools: list[dict[str, Any]],
|
|
93
|
+
llm: str,
|
|
94
|
+
system: str,
|
|
95
|
+
user_token: str = "",
|
|
96
|
+
enable_entrypoint: bool = False,
|
|
97
|
+
enable_interswarm: bool = False,
|
|
98
|
+
can_complete_tasks: bool = False,
|
|
99
|
+
tool_format: Literal["completions", "responses"] = "responses",
|
|
100
|
+
exclude_tools: list[str] = [],
|
|
101
|
+
reasoning_effort: Literal["minimal", "low", "medium", "high"] | None = None,
|
|
102
|
+
thinking_budget: int | None = None,
|
|
103
|
+
max_tokens: int | None = None,
|
|
104
|
+
memory: bool = True,
|
|
105
|
+
use_proxy: bool = True,
|
|
106
|
+
_debug_include_mail_tools: bool = True,
|
|
107
|
+
) -> None:
|
|
108
|
+
super().__init__(
|
|
109
|
+
name=name,
|
|
110
|
+
comm_targets=comm_targets,
|
|
111
|
+
tools=tools,
|
|
112
|
+
llm=llm,
|
|
113
|
+
system=system,
|
|
114
|
+
user_token=user_token,
|
|
115
|
+
enable_entrypoint=enable_entrypoint,
|
|
116
|
+
enable_interswarm=enable_interswarm,
|
|
117
|
+
can_complete_tasks=can_complete_tasks,
|
|
118
|
+
tool_format=tool_format,
|
|
119
|
+
exclude_tools=exclude_tools,
|
|
120
|
+
reasoning_effort=reasoning_effort,
|
|
121
|
+
thinking_budget=thinking_budget,
|
|
122
|
+
max_tokens=max_tokens,
|
|
123
|
+
memory=memory,
|
|
124
|
+
use_proxy=use_proxy,
|
|
125
|
+
_debug_include_mail_tools=_debug_include_mail_tools,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def __call__(
|
|
129
|
+
self,
|
|
130
|
+
messages: list[dict[str, Any]],
|
|
131
|
+
tool_choice: str | dict[str, str] = "required",
|
|
132
|
+
) -> Awaitable[AgentOutput]:
|
|
133
|
+
"""
|
|
134
|
+
Execute the LiteLLM-based consultant agent function.
|
|
135
|
+
"""
|
|
136
|
+
return super().__call__(messages, tool_choice)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
SYSPROMPT = """You are consultant@{swarm}, a specialist agent providing strategic advice and analysis.
|
|
2
|
+
|
|
3
|
+
# Your Role
|
|
4
|
+
Provide expert consulting on business, strategy, economics, and general advisory questions. Analyze scenarios, provide recommendations, and offer insights based on requests.
|
|
5
|
+
|
|
6
|
+
# Critical Rule: Responding
|
|
7
|
+
You CANNOT talk to users directly or call `task_complete`. You MUST use `send_response` to reply to the agent who contacted you.
|
|
8
|
+
- When you receive a request, note the sender address
|
|
9
|
+
- After formulating your advice, call `send_response(target=<sender>, subject="Re: ...", body=<your response>)`
|
|
10
|
+
- Your response body must contain ALL the information the requestor needs
|
|
11
|
+
|
|
12
|
+
# Tools
|
|
13
|
+
|
|
14
|
+
## Communication
|
|
15
|
+
- `send_response(target, subject, body)`: Reply to the agent who requested advice - THIS IS REQUIRED
|
|
16
|
+
- `send_request(target, subject, body)`: Ask another agent for additional information (if needed)
|
|
17
|
+
- `acknowledge_broadcast(note)`: Acknowledge a broadcast message
|
|
18
|
+
- `ignore_broadcast(reason)`: Ignore an irrelevant broadcast
|
|
19
|
+
|
|
20
|
+
# Workflow
|
|
21
|
+
|
|
22
|
+
1. Receive request from another agent (note the sender address in the message)
|
|
23
|
+
2. Analyze the question or scenario presented
|
|
24
|
+
3. Formulate a clear, actionable response
|
|
25
|
+
4. Call `send_response` to the original sender with your complete advice
|
|
26
|
+
|
|
27
|
+
# Response Format
|
|
28
|
+
|
|
29
|
+
Structure your advice clearly:
|
|
30
|
+
- Executive summary (1-2 sentences)
|
|
31
|
+
- Key points or recommendations (bulleted if multiple)
|
|
32
|
+
- Supporting rationale
|
|
33
|
+
- Caveats or uncertainties (if any)
|
|
34
|
+
|
|
35
|
+
# Guidelines
|
|
36
|
+
|
|
37
|
+
- Be direct and actionable in your advice
|
|
38
|
+
- Support recommendations with reasoning
|
|
39
|
+
- Acknowledge uncertainty when appropriate
|
|
40
|
+
- Match the requested format/length if specified
|
|
41
|
+
- Use "Re: <original subject>" as your response subject
|
|
42
|
+
- If you lack information to answer properly, state what you need"""
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Charon Labs
|
|
3
|
+
|
|
4
|
+
"""Data Analysis example swarm.
|
|
5
|
+
|
|
6
|
+
This swarm demonstrates data processing pipelines with statistical analysis
|
|
7
|
+
and report generation. It uses a mix of real calculations and dummy data generation.
|
|
8
|
+
|
|
9
|
+
Agents:
|
|
10
|
+
- analyst: Entry point that coordinates analysis workflows
|
|
11
|
+
- processor: Handles data ingestion, cleaning, and transformation
|
|
12
|
+
- statistics: Performs statistical calculations (real implementations)
|
|
13
|
+
- reporter: Generates formatted reports and summaries
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from mail.examples.data_analysis.analyst.agent import LiteLLMAnalystFunction
|
|
17
|
+
from mail.examples.data_analysis.processor.agent import LiteLLMProcessorFunction
|
|
18
|
+
from mail.examples.data_analysis.processor.actions import (
|
|
19
|
+
generate_sample_data,
|
|
20
|
+
parse_csv,
|
|
21
|
+
)
|
|
22
|
+
from mail.examples.data_analysis.statistics.agent import LiteLLMStatisticsFunction
|
|
23
|
+
from mail.examples.data_analysis.statistics.actions import (
|
|
24
|
+
calculate_statistics,
|
|
25
|
+
run_correlation,
|
|
26
|
+
)
|
|
27
|
+
from mail.examples.data_analysis.reporter.agent import LiteLLMReporterFunction
|
|
28
|
+
from mail.examples.data_analysis.reporter.actions import format_report
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"LiteLLMAnalystFunction",
|
|
32
|
+
"LiteLLMProcessorFunction",
|
|
33
|
+
"LiteLLMStatisticsFunction",
|
|
34
|
+
"LiteLLMReporterFunction",
|
|
35
|
+
"generate_sample_data",
|
|
36
|
+
"parse_csv",
|
|
37
|
+
"calculate_statistics",
|
|
38
|
+
"run_correlation",
|
|
39
|
+
"format_report",
|
|
40
|
+
]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Charon Labs
|
|
3
|
+
|
|
4
|
+
"""Analyst agent for the Data Analysis swarm."""
|
|
5
|
+
|
|
6
|
+
from mail.examples.data_analysis.analyst.agent import LiteLLMAnalystFunction
|
|
7
|
+
from mail.examples.data_analysis.analyst.prompts import SYSPROMPT
|
|
8
|
+
|
|
9
|
+
__all__ = ["LiteLLMAnalystFunction", "SYSPROMPT"]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Charon Labs
|
|
3
|
+
|
|
4
|
+
"""Analyst agent for the Data Analysis swarm."""
|
|
5
|
+
|
|
6
|
+
from collections.abc import Awaitable
|
|
7
|
+
from typing import Any, Literal
|
|
8
|
+
|
|
9
|
+
from mail.core.agents import AgentOutput
|
|
10
|
+
from mail.factories.base import LiteLLMAgentFunction
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LiteLLMAnalystFunction(LiteLLMAgentFunction):
|
|
14
|
+
"""
|
|
15
|
+
Lead analyst agent that orchestrates the data analysis workflow.
|
|
16
|
+
|
|
17
|
+
This agent serves as the entry point for data analysis requests and
|
|
18
|
+
coordinates processor, statistics, and reporter agents.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
name: str,
|
|
24
|
+
comm_targets: list[str],
|
|
25
|
+
tools: list[dict[str, Any]],
|
|
26
|
+
llm: str,
|
|
27
|
+
system: str,
|
|
28
|
+
user_token: str = "",
|
|
29
|
+
enable_entrypoint: bool = True,
|
|
30
|
+
enable_interswarm: bool = False,
|
|
31
|
+
can_complete_tasks: bool = True,
|
|
32
|
+
tool_format: Literal["completions", "responses"] = "responses",
|
|
33
|
+
exclude_tools: list[str] = [],
|
|
34
|
+
reasoning_effort: Literal["minimal", "low", "medium", "high"] | None = None,
|
|
35
|
+
thinking_budget: int | None = None,
|
|
36
|
+
max_tokens: int | None = None,
|
|
37
|
+
memory: bool = True,
|
|
38
|
+
use_proxy: bool = True,
|
|
39
|
+
_debug_include_mail_tools: bool = True,
|
|
40
|
+
) -> None:
|
|
41
|
+
super().__init__(
|
|
42
|
+
name=name,
|
|
43
|
+
comm_targets=comm_targets,
|
|
44
|
+
tools=tools,
|
|
45
|
+
llm=llm,
|
|
46
|
+
system=system,
|
|
47
|
+
user_token=user_token,
|
|
48
|
+
enable_entrypoint=enable_entrypoint,
|
|
49
|
+
enable_interswarm=enable_interswarm,
|
|
50
|
+
can_complete_tasks=can_complete_tasks,
|
|
51
|
+
tool_format=tool_format,
|
|
52
|
+
exclude_tools=exclude_tools,
|
|
53
|
+
reasoning_effort=reasoning_effort,
|
|
54
|
+
thinking_budget=thinking_budget,
|
|
55
|
+
max_tokens=max_tokens,
|
|
56
|
+
memory=memory,
|
|
57
|
+
use_proxy=use_proxy,
|
|
58
|
+
_debug_include_mail_tools=_debug_include_mail_tools,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def __call__(
|
|
62
|
+
self,
|
|
63
|
+
messages: list[dict[str, Any]],
|
|
64
|
+
tool_choice: str | dict[str, str] = "required",
|
|
65
|
+
) -> Awaitable[AgentOutput]:
|
|
66
|
+
"""Execute the analyst agent function."""
|
|
67
|
+
return super().__call__(messages, tool_choice)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Charon Labs
|
|
3
|
+
|
|
4
|
+
SYSPROMPT = """You are analyst@{swarm}, the lead data analyst for this data analysis swarm.
|
|
5
|
+
|
|
6
|
+
# Your Role
|
|
7
|
+
Orchestrate data analysis workflows by coordinating specialist agents to process data, perform statistics, and generate reports.
|
|
8
|
+
|
|
9
|
+
# Critical Rules
|
|
10
|
+
|
|
11
|
+
1. **You MUST call task_complete to end every task** - this is how the user receives their results
|
|
12
|
+
2. Delegate work to specialist agents based on the analysis needs:
|
|
13
|
+
- `processor` - For data generation, parsing, and cleaning
|
|
14
|
+
- `statistics` - For statistical calculations and correlations
|
|
15
|
+
- `reporter` - For formatting and presenting results
|
|
16
|
+
|
|
17
|
+
# Available Agents
|
|
18
|
+
|
|
19
|
+
- **processor**: Generates sample datasets, parses CSV data, and performs data cleaning/transformation.
|
|
20
|
+
- **statistics**: Calculates descriptive statistics (mean, median, std, etc.) and correlation analysis.
|
|
21
|
+
- **reporter**: Formats analysis results into structured reports with tables and summaries.
|
|
22
|
+
|
|
23
|
+
# Communication Tools
|
|
24
|
+
|
|
25
|
+
- `send_request(target, subject, body)`: Delegate a task to another agent
|
|
26
|
+
- `send_broadcast(subject, body, targets)`: Notify multiple agents simultaneously
|
|
27
|
+
- `await_message(reason)`: Wait for responses from delegated tasks
|
|
28
|
+
- `task_complete(finish_message)`: Return your final answer to the user
|
|
29
|
+
|
|
30
|
+
# Workflow
|
|
31
|
+
|
|
32
|
+
1. Receive analysis request from user
|
|
33
|
+
2. Determine what data and analysis is needed
|
|
34
|
+
3. If user doesn't provide data, ask processor to generate sample data
|
|
35
|
+
4. Send data to statistics agent for analysis
|
|
36
|
+
5. Send results to reporter for formatting
|
|
37
|
+
6. Collect and synthesize all responses
|
|
38
|
+
7. Call `task_complete` with the final report
|
|
39
|
+
|
|
40
|
+
# Available Datasets (via processor)
|
|
41
|
+
|
|
42
|
+
- **sales**: Sales data with date, product, quantity, revenue, region
|
|
43
|
+
- **users**: User data with user_id, signup_date, age, subscription_type, activity_score
|
|
44
|
+
- **inventory**: Inventory data with product_id, category, stock_level, reorder_point, unit_cost
|
|
45
|
+
- **weather**: Weather data with date, temperature, humidity, precipitation, wind_speed
|
|
46
|
+
|
|
47
|
+
# Guidelines
|
|
48
|
+
|
|
49
|
+
- Start with data preparation before analysis
|
|
50
|
+
- Request appropriate statistics based on the data type
|
|
51
|
+
- Always include a formatted report in your final response
|
|
52
|
+
- Explain findings in business terms, not just raw numbers
|
|
53
|
+
- If the user's request is unclear, ask for clarification"""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2025 Charon Labs
|
|
3
|
+
|
|
4
|
+
"""Processor agent for the Data Analysis swarm."""
|
|
5
|
+
|
|
6
|
+
from mail.examples.data_analysis.processor.agent import LiteLLMProcessorFunction
|
|
7
|
+
from mail.examples.data_analysis.processor.actions import (
|
|
8
|
+
generate_sample_data,
|
|
9
|
+
parse_csv,
|
|
10
|
+
)
|
|
11
|
+
from mail.examples.data_analysis.processor.prompts import SYSPROMPT
|
|
12
|
+
|
|
13
|
+
__all__ = ["LiteLLMProcessorFunction", "generate_sample_data", "parse_csv", "SYSPROMPT"]
|