Skip to content

Commit 9941800

Browse files
committed
feat(ag-ui): configure loggers from the cli
Allow the loggers to be configured from the CLI, so that users can control the logging level of other modules when running the AG-UI examples.
1 parent f091c9d commit 9941800

File tree

1 file changed

+11
-8
lines changed
  • examples/pydantic_ai_ag_ui_examples/cli

1 file changed

+11
-8
lines changed

examples/pydantic_ai_ag_ui_examples/cli/args.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Args:
1515
port: int
1616
reload: bool
1717
log_level: str
18-
loggers: tuple[str, ...]
18+
loggers: list[str]
1919

2020
def log_config(self) -> dict[str, Any]:
2121
"""Return the logging configuration based on the log level."""
@@ -30,14 +30,9 @@ def log_config(self) -> dict[str, Any]:
3030
return log_config
3131

3232

33-
def parse_args(
34-
loggers: tuple[str, ...] = ('pydantic_ai_ag_ui.adapter',),
35-
) -> Args:
33+
def parse_args() -> Args:
3634
"""Parse command line arguments for the PydanticAI AG-UI servers.
3735
38-
Args:
39-
loggers: A tuple of logger names to configure. Defaults to the adapter logger.
40-
4136
Returns:
4237
Args: A dataclass containing the parsed command line arguments.
4338
"""
@@ -66,6 +61,14 @@ def parse_args(
6661
default='info',
6762
help='Adapter log level (default: info)',
6863
)
64+
parser.add_argument(
65+
'--loggers',
66+
nargs='*',
67+
default=[
68+
'pydantic_ai_ag_ui.adapter',
69+
],
70+
help='Logger names to configure (default: adapter and model loggers)',
71+
)
6972

7073
args: argparse.Namespace = parser.parse_args()
71-
return Args(loggers=loggers, **vars(args))
74+
return Args(**vars(args))

0 commit comments

Comments
 (0)