Skip to content

client.resources

crp.sdk.proxies_more._ResourcesProxy

Resource management proxy (§6.8, §6.12).

Exposes the adaptive allocator, cost model, overhead manager, resource manager, and a cost-estimation helper.

Source code in crp/sdk/proxies_more.py
class _ResourcesProxy:
    """Resource management proxy (§6.8, §6.12).

    Exposes the adaptive allocator, cost model, overhead manager, resource
    manager, and a cost-estimation helper.
    """

    def __init__(self, orchestrator: Any) -> None:
        self._orchestrator = orchestrator

    def allocator(self) -> Any:
        """Return a fresh ``AdaptiveAllocator``.

        Returns:
            AdaptiveAllocator instance.
        """
        from crp.resources.adaptive_allocator import AdaptiveAllocator
        from crp.resources.overhead_manager import OverheadBudgetManager
        from crp.resources.resource_manager import ResourceManager

        return AdaptiveAllocator(
            resource_manager=ResourceManager(),
            overhead_manager=OverheadBudgetManager(),
        )

    def cost_model(self) -> Any:
        """Return a fresh ``CostModel``.

        Returns:
            CostModel instance.
        """
        from crp.resources.cost_model import CostModel

        return CostModel()

    def overhead_manager(self) -> Any:
        """Return a fresh ``OverheadBudgetManager``.

        Returns:
            OverheadBudgetManager instance.
        """
        from crp.resources.overhead_manager import OverheadBudgetManager

        return OverheadBudgetManager()

    def resource_manager(self) -> Any:
        """Return a fresh ``ResourceManager``.

        Returns:
            ResourceManager instance.
        """
        from crp.resources.resource_manager import ResourceManager

        return ResourceManager()

    def estimate_cost(self, input_tokens: int = 0, output_tokens: int = 0, model: str = "gpt-4o") -> Any:
        """Estimate cost for a given token budget and model.

        Args:
            input_tokens: Number of input tokens.
            output_tokens: Number of output tokens.
            model: Model identifier used for pricing lookup.

        Returns:
            SimpleNamespace with ``total_usd`` and ``pricing``.
        """
        from crp.resources.cost_model import KNOWN_PRICING, ProviderPricing

        pricing = KNOWN_PRICING.get(model, ProviderPricing(provider_name=model))
        return SimpleNamespace(
            total_usd=pricing.total_cost(input_tokens, output_tokens),
            pricing=pricing,
        )

allocator()

Return a fresh AdaptiveAllocator.

Returns:

Type Description
Any

AdaptiveAllocator instance.

Source code in crp/sdk/proxies_more.py
def allocator(self) -> Any:
    """Return a fresh ``AdaptiveAllocator``.

    Returns:
        AdaptiveAllocator instance.
    """
    from crp.resources.adaptive_allocator import AdaptiveAllocator
    from crp.resources.overhead_manager import OverheadBudgetManager
    from crp.resources.resource_manager import ResourceManager

    return AdaptiveAllocator(
        resource_manager=ResourceManager(),
        overhead_manager=OverheadBudgetManager(),
    )

cost_model()

Return a fresh CostModel.

Returns:

Type Description
Any

CostModel instance.

Source code in crp/sdk/proxies_more.py
def cost_model(self) -> Any:
    """Return a fresh ``CostModel``.

    Returns:
        CostModel instance.
    """
    from crp.resources.cost_model import CostModel

    return CostModel()

overhead_manager()

Return a fresh OverheadBudgetManager.

Returns:

Type Description
Any

OverheadBudgetManager instance.

Source code in crp/sdk/proxies_more.py
def overhead_manager(self) -> Any:
    """Return a fresh ``OverheadBudgetManager``.

    Returns:
        OverheadBudgetManager instance.
    """
    from crp.resources.overhead_manager import OverheadBudgetManager

    return OverheadBudgetManager()

resource_manager()

Return a fresh ResourceManager.

Returns:

Type Description
Any

ResourceManager instance.

Source code in crp/sdk/proxies_more.py
def resource_manager(self) -> Any:
    """Return a fresh ``ResourceManager``.

    Returns:
        ResourceManager instance.
    """
    from crp.resources.resource_manager import ResourceManager

    return ResourceManager()

estimate_cost(input_tokens=0, output_tokens=0, model='gpt-4o')

Estimate cost for a given token budget and model.

Parameters:

Name Type Description Default
input_tokens int

Number of input tokens.

0
output_tokens int

Number of output tokens.

0
model str

Model identifier used for pricing lookup.

'gpt-4o'

Returns:

Type Description
Any

SimpleNamespace with total_usd and pricing.

Source code in crp/sdk/proxies_more.py
def estimate_cost(self, input_tokens: int = 0, output_tokens: int = 0, model: str = "gpt-4o") -> Any:
    """Estimate cost for a given token budget and model.

    Args:
        input_tokens: Number of input tokens.
        output_tokens: Number of output tokens.
        model: Model identifier used for pricing lookup.

    Returns:
        SimpleNamespace with ``total_usd`` and ``pricing``.
    """
    from crp.resources.cost_model import KNOWN_PRICING, ProviderPricing

    pricing = KNOWN_PRICING.get(model, ProviderPricing(provider_name=model))
    return SimpleNamespace(
        total_usd=pricing.total_cost(input_tokens, output_tokens),
        pricing=pricing,
    )