Skip to content

ccproxy.plugins.max_tokens.plugin

ccproxy.plugins.max_tokens.plugin

Max tokens plugin implementation.

MaxTokensRuntime

MaxTokensRuntime(manifest)

Bases: SystemPluginRuntime

Runtime for max_tokens plugin.

Source code in ccproxy/plugins/max_tokens/plugin.py
def __init__(self, manifest: PluginManifest):
    """Initialize runtime."""
    super().__init__(manifest)
    self.config: MaxTokensConfig | None = None
    self.service: TokenLimitsService | None = None
    self.hook: MaxTokensHook | None = None
    self.hook_registered = False

MaxTokensFactory

MaxTokensFactory()

Bases: SystemPluginFactory

Factory for max_tokens plugin.

Source code in ccproxy/plugins/max_tokens/plugin.py
def __init__(self) -> None:
    """Initialize factory with manifest."""
    # Create manifest - max_tokens logic is now integrated into HTTP adapter
    manifest = PluginManifest(
        name="max_tokens",
        version="0.1.0",
        description="Automatically sets max_tokens based on model limits when missing or invalid",
        is_provider=False,
        config_class=MaxTokensConfig,
        provides=["max_tokens"],  # This plugin provides the max_tokens service
    )

    # Initialize with manifest
    super().__init__(manifest)

create_runtime

create_runtime()

Create runtime instance.

Source code in ccproxy/plugins/max_tokens/plugin.py
def create_runtime(self) -> MaxTokensRuntime:
    """Create runtime instance."""
    return MaxTokensRuntime(self.manifest)