feat: add Parlant configurable log level
Browse filesRead PARLANT_LOG_LEVEL env var to control Parlant server verbosity.
Defaults to INFO. Supports trace, debug, info, warning, error.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- trialpath/agent/setup.py +15 -0
trialpath/agent/setup.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
"""Parlant server and agent initialization."""
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
from parlant.sdk import Agent, NLPServices, Server
|
| 4 |
|
| 5 |
AGENT_NAME = "Patient Trial Copilot"
|
|
@@ -10,16 +13,28 @@ AGENT_DESCRIPTION = (
|
|
| 10 |
"where additional data could unlock new trial options."
|
| 11 |
)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
async def create_server_and_agent(
|
| 15 |
host: str = "0.0.0.0",
|
| 16 |
port: int = 8800,
|
| 17 |
) -> tuple[Server, Agent]:
|
| 18 |
"""Create and start Parlant server with the TrialPath agent."""
|
|
|
|
|
|
|
|
|
|
| 19 |
server = Server(
|
| 20 |
nlp_service=NLPServices.gemini,
|
| 21 |
host=host,
|
| 22 |
port=port,
|
|
|
|
| 23 |
)
|
| 24 |
await server.__aenter__()
|
| 25 |
|
|
|
|
| 1 |
"""Parlant server and agent initialization."""
|
| 2 |
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from parlant.core.loggers import LogLevel
|
| 6 |
from parlant.sdk import Agent, NLPServices, Server
|
| 7 |
|
| 8 |
AGENT_NAME = "Patient Trial Copilot"
|
|
|
|
| 13 |
"where additional data could unlock new trial options."
|
| 14 |
)
|
| 15 |
|
| 16 |
+
_LOG_LEVEL_MAP = {
|
| 17 |
+
"trace": LogLevel.TRACE,
|
| 18 |
+
"debug": LogLevel.DEBUG,
|
| 19 |
+
"info": LogLevel.INFO,
|
| 20 |
+
"warning": LogLevel.WARNING,
|
| 21 |
+
"error": LogLevel.ERROR,
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
|
| 25 |
async def create_server_and_agent(
|
| 26 |
host: str = "0.0.0.0",
|
| 27 |
port: int = 8800,
|
| 28 |
) -> tuple[Server, Agent]:
|
| 29 |
"""Create and start Parlant server with the TrialPath agent."""
|
| 30 |
+
log_level_str = os.environ.get("PARLANT_LOG_LEVEL", "info").lower()
|
| 31 |
+
log_level = _LOG_LEVEL_MAP.get(log_level_str, LogLevel.INFO)
|
| 32 |
+
|
| 33 |
server = Server(
|
| 34 |
nlp_service=NLPServices.gemini,
|
| 35 |
host=host,
|
| 36 |
port=port,
|
| 37 |
+
log_level=log_level,
|
| 38 |
)
|
| 39 |
await server.__aenter__()
|
| 40 |
|