Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ccproxy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ def start_litellm(config_dir: Path, args: list[str] | None = None, detach: bool

cmd = [str(litellm_path), "--config", str(config_path)]

# Pass num_workers from ccproxy.yaml litellm section if configured
ccproxy_config_path = config_dir / "ccproxy.yaml"
if ccproxy_config_path.exists():
with ccproxy_config_path.open() as f:
ccproxy_config = yaml.safe_load(f)
if ccproxy_config:
num_workers = ccproxy_config.get("litellm", {}).get("num_workers")
if num_workers is not None:
cmd.extend(["--num_workers", str(num_workers)])

# Add any additional arguments
if args:
cmd.extend(args)
Expand Down
28 changes: 28 additions & 0 deletions tests/test_num_workers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Tests for num_workers configuration passthrough."""

from pathlib import Path
from unittest.mock import Mock, patch

import pytest

from ccproxy.cli import start_litellm


class TestNumWorkers:
"""Test suite for num_workers in ccproxy.yaml."""

@patch("subprocess.run")
def test_num_workers_passed_to_litellm(self, mock_run: Mock, tmp_path: Path) -> None:
"""Test num_workers from ccproxy.yaml is passed as --num_workers to litellm."""
(tmp_path / "config.yaml").write_text("model_list: []")
(tmp_path / "ccproxy.yaml").write_text(
"ccproxy:\n handler: 'ccproxy.handler:CCProxyHandler'\nlitellm:\n num_workers: 8\n"
)
mock_run.return_value = Mock(returncode=0)

with pytest.raises(SystemExit):
start_litellm(tmp_path)

cmd = mock_run.call_args[0][0]
assert "--num_workers" in cmd, f"--num_workers missing from command: {cmd}"
assert cmd[cmd.index("--num_workers") + 1] == "8"