-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: validate gateway server config fields with typed model (closes #3050) #3060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,34 @@ | |
| from praisonaiagents import Agent, GatewayConfig, SessionConfig | ||
|
|
||
| # Configure the gateway | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| class ServerConfig(BaseModel): | ||
| host: str = "0.0.0.0" | ||
| port: int = 8000 | ||
| drain_timeout: int = 30 | ||
| reload_drain_timeout: int = 60 | ||
| max_connections: int = 1000 | ||
| heartbeat_interval: int = 30 | ||
|
|
||
| class GatewayConfig: | ||
| def __init__(self, host="0.0.0.0", port=8000, drain_timeout=30, reload_drain_timeout=60, max_connections=1000, heartbeat_interval=30, session_config=None): | ||
|
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||
| self.host = host | ||
| self.port = port | ||
| self.drain_timeout = drain_timeout | ||
| self.reload_drain_timeout = reload_drain_timeout | ||
| self.max_connections = max_connections | ||
| self.heartbeat_interval = heartbeat_interval | ||
| self.session_config = session_config or SessionConfig() | ||
| self.ws_url = f"ws://{self.host}:{self.port}" | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redefining GatewayConfig and ServerConfig directly inside the example file shadows the imported GatewayConfig from praisonaiagents (imported on line 8) and does not actually update the library's configuration. The Pydantic validation model ServerConfig and the updated GatewayConfig should be implemented in the library itself (specifically in src/praisonai-agents/praisonaiagents/gateway/config.py), and this example file should only import and use them. |
||
| 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 | ||
| timeout=3600, | ||
| max_messages=500, | ||
| ) | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.