Skip to content

Commit 86e680a

Browse files
committed
added --litellm-tracing parameter
1 parent a0d072b commit 86e680a

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

nerve/cli/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def run(
3131
args.log_path,
3232
level="DEBUG" if args.debug else "SUCCESS" if args.quiet else "INFO",
3333
litellm_debug=args.litellm_debug,
34+
litellm_tracing=args.litellm_tracing,
3435
)
3536
logger.info(f"🧠 nerve v{nerve.__version__}")
3637

nerve/cli/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def _get_run_args(
7070
bool,
7171
typer.Option("--litellm-debug", help="Enable litellm debug logging"),
7272
] = False,
73+
litellm_tracing: t.Annotated[
74+
str | None,
75+
typer.Option("--litellm-tracing", help="Set litellm callbacks for tracing"),
76+
] = None,
7377
quiet: t.Annotated[
7478
bool,
7579
typer.Option("--quiet", "-q", help="Quiet mode"),
@@ -112,6 +116,7 @@ def _get_run_args(
112116
interactive=interactive,
113117
debug=debug,
114118
litellm_debug=litellm_debug,
119+
litellm_tracing=litellm_tracing,
115120
quiet=quiet,
116121
max_steps=max_steps,
117122
max_cost=max_cost,

nerve/runtime/logging.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def init(
1414
log_path: pathlib.Path | None = None,
1515
level: str = "INFO",
1616
litellm_debug: bool = False,
17+
litellm_tracing: str | None = None,
1718
target: t.TextIO = sys.stderr,
1819
) -> None:
1920
"""
@@ -23,6 +24,7 @@ def init(
2324
log_path: The path to the log file.
2425
level: The log level to use.
2526
litellm_debug: Whether to enable litellm debug logging.
27+
litellm_tracing: The callback to set for litellm tracing.
2628
"""
2729

2830
if level != "DEBUG":
@@ -40,6 +42,9 @@ def init(
4042
# https://github.com/BerriAI/litellm/issues/4825
4143
litellm.suppress_debug_info = True
4244

45+
if litellm_tracing:
46+
litellm.callbacks = [litellm_tracing]
47+
4348
if log_path:
4449
logger.add(log_path, format=format, level=level)
4550

nerve/runtime/runner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Arguments(BaseModel):
2323
interactive: bool
2424
debug: bool
2525
litellm_debug: bool
26+
litellm_tracing: str | None
2627
quiet: bool
2728
max_steps: int
2829
max_cost: float
@@ -72,6 +73,10 @@ def _create_command_line(
7273
# if run_args.litellm_debug:
7374
# command_line.append("--litellm-debug")
7475

76+
if run_args.litellm_tracing:
77+
command_line.append("--litellm-tracing")
78+
command_line.append(run_args.litellm_tracing)
79+
7580
# if the task is set, add it to the command line
7681
if "task" in input_state:
7782
command_line.append("--task")

0 commit comments

Comments
 (0)