mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 12:47:55 -10:00
Adds load_gateway_config integration coverage for the #3050 validation path and documents load-time gateway block checks in the example. Supersedes #3060; core fix landed in #3079. Co-authored-by: botbikamordehai2-sketch <[email protected]>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""
|
|
Gateway Example - Multi-Agent Coordination
|
|
|
|
This example demonstrates how to use the Gateway for coordinating
|
|
multiple agents and managing real-time communication.
|
|
"""
|
|
|
|
from praisonaiagents import Agent, GatewayConfig, SessionConfig
|
|
|
|
# Configure the gateway using the typed SDK GatewayConfig.
|
|
# In gateway.yaml, the optional ``gateway:`` block is validated at load time (#3050).
|
|
gateway_config = GatewayConfig(
|
|
host="127.0.0.1",
|
|
port=8765,
|
|
max_connections=100,
|
|
heartbeat_interval=30,
|
|
session_config=SessionConfig(
|
|
timeout=3600, # 1 hour session timeout
|
|
max_messages=500,
|
|
)
|
|
)
|
|
|
|
# Create specialized agents
|
|
researcher = Agent(
|
|
name="researcher",
|
|
instructions="You research topics thoroughly and provide detailed information.",
|
|
llm="gpt-4o-mini"
|
|
)
|
|
|
|
writer = Agent(
|
|
name="writer",
|
|
instructions="You write clear, engaging content based on research.",
|
|
llm="gpt-4o-mini"
|
|
)
|
|
|
|
# Example: Simple agent interaction
|
|
if __name__ == "__main__":
|
|
print("Gateway Configuration:")
|
|
print(f" Host: {gateway_config.host}")
|
|
print(f" Port: {gateway_config.port}")
|
|
print(f" WebSocket URL: {gateway_config.ws_url}")
|
|
print(f" Max Connections: {gateway_config.max_connections}")
|
|
print()
|
|
|
|
# Test agent
|
|
response = researcher.start("What are the key benefits of multi-agent systems?")
|
|
print("Researcher Response:")
|
|
print(response)
|