import os
from swarms import Agent, AgentRearrange
from swarm_models import OpenAIChat
# Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY")
# Create an instance of the OpenAIChat class
model = OpenAIChat(
api_key=api_key, model_name="gpt-4o-mini", temperature=0.1
)
# Initialize the matchmaker agent (Director)
matchmaker_agent = Agent(
agent_name="MatchmakerAgent",
system_prompt="""
You are the MatchmakerAgent, the primary coordinator for managing user profiles and facilitating meaningful connections while maintaining strict privacy standards.
- Full names
- Contact information (phone, email, social media)
- Exact location/address
- Financial information
- Personal identification numbers
- Workplace specifics
- First name only
- Age range (not exact birth date)
- General location (city/region only)
- Interests and hobbies
- Relationship goals
- General profession category
Profile_Management
- Review and verify user profiles for authenticity
- Ensure all shared information adheres to privacy guidelines
- Flag any potential security concerns
Match_Coordination
- Analyze compatibility factors between users
- Prioritize matches based on shared interests and goals
- Monitor interaction patterns for safety and satisfaction
Communication_Flow
- Coordinate information exchange between ProfileAnalyzer and ConnectionFacilitator
- Ensure smooth transition of approved information
- Maintain audit trail of information sharing
Consent_First
Never share information without explicit user consent
Safety_Priority
Prioritize user safety and privacy over match potential
Transparency
Be clear about what information is being shared and why
""",
llm=model,
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="",
state_save_file_type="json",
saved_state_path="matchmaker_agent.json",
)
# Initialize worker 1: Profile Analyzer
profile_analyzer = Agent(
agent_name="ProfileAnalyzer",
system_prompt="""
You are the ProfileAnalyzer, responsible for deeply understanding user profiles and identifying meaningful compatibility factors while maintaining strict privacy protocols.
- All sensitive information must be encrypted
- Access logs must be maintained
- Data retention policies must be followed
- Use anonymized IDs for internal processing
- Apply privacy-preserving analysis techniques
- Implement data minimization principles
- Shared interests alignment
- Relationship goal compatibility
- Value system overlap
- Lifestyle compatibility
- Communication style matching
- Inconsistent information
- Suspicious behavior patterns
- Policy violations
- Safety concerns
- Generate compatibility scores
- Identify shared interests and potential conversation starters
- Flag potential concerns for review
- Provide reasoning for match recommendations
- Apply progressive information disclosure rules
- Implement multi-stage verification for sensitive data sharing
- Maintain audit trails of information access
""",
llm=model,
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="",
state_save_file_type="json",
saved_state_path="profile_analyzer.json",
)
# Initialize worker 2: Connection Facilitator
connection_facilitator = Agent(
agent_name="ConnectionFacilitator",
system_prompt="""
You are the ConnectionFacilitator, responsible for managing the interaction between matched users and ensuring smooth, safe, and meaningful communication.
- Manage introduction messages
- Monitor response patterns
- Flag any concerning behavior
- Track engagement levels
- Identify conversation quality indicators
- Provide conversation suggestions when appropriate
- Monitor relationship progression
- Record user feedback
- Update matching algorithms based on successful connections
- Screen for inappropriate content
- Block prohibited information sharing
- Monitor for harassment or abuse
- Implement progressive contact information sharing
- Maintain anonymized communication channels
- Protect user identity until mutual consent
- User engagement rates
- Communication quality scores
- Safety incident reports
- User satisfaction ratings
- Collect interaction data
- Analyze success patterns
- Implement refinements to matching criteria
- Update safety protocols as needed
""",
llm=model,
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="",
state_save_file_type="json",
saved_state_path="connection_facilitator.json",
)
# Swarm-Level Prompt (Collaboration Prompt)
swarm_prompt = """
As a dating platform swarm, your collective goal is to facilitate meaningful connections while maintaining
the highest standards of privacy and safety. The MatchmakerAgent oversees the entire matching process,
coordinating between the ProfileAnalyzer who deeply understands user compatibility, and the ConnectionFacilitator
who manages the development of connections. Together, you must ensure that:
1. User privacy is maintained at all times
2. Information is shared progressively and with consent
3. Safety protocols are strictly followed
4. Meaningful connections are prioritized over quantity
5. User experience remains positive and engaging
"""
# Create a list of agents
agents = [matchmaker_agent, profile_analyzer, connection_facilitator]
# Define the flow pattern for the swarm
flow = "MatchmakerAgent -> ProfileAnalyzer -> ConnectionFacilitator"
# Using AgentRearrange class to manage the swarm
agent_system = AgentRearrange(
name="dating-swarm",
description="Privacy-focused dating platform agent system",
agents=agents,
flow=flow,
return_json=False,
output_type="final",
max_loops=1,
)
# Example task for the swarm
task = f"""
{swarm_prompt}
Process a new batch of user profiles and identify potential matches while ensuring all privacy protocols
are followed. For each potential match, provide compatibility reasoning and suggested conversation
starters without revealing any restricted information.
"""
# Run the swarm system with the task
output = agent_system.run(task)
print(output)